Web/API/ValidityState/badInput

From Get docs

The read-only badInput property of a ValidityState object indicates if the user has provided input that the browser is unable to convert. For example, if you have a number input element whose content is a string. Note: While this is unsupported in Internet Explorer, any non-numeric value will be dismissed from the field if it is a number input.

Example

<input type="number" id="age">
var input = document.getElementById("age");
if (input.validity.badInput) {
  console.log("Bad input detected…");
} else {
  console.log("Content of input ok.");
}

Specifications

Specification Status Comment
HTML Living StandardThe definition of 'ValidityState.badInput' in that specification. Living Standard Live Standard
HTML 5.1The definition of 'ValidityState.badInput' in that specification. Recommendation No change from the previous snapshot HTML5.
HTML5The definition of 'ValidityState.badInput' in that specification. Recommendation First snapshot of  HTML Living Standard containing this interface.

Browser compatibility

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
badInput Chrome

Full support 25

Edge

Full support 14

Firefox

Full support 29

IE

No support No

Opera

Full support 15

Safari

Full support 11

WebView Android

Full support 4.4

Chrome Android

Full support Yes

Firefox Android

Full support 64

Opera Android

Full support 14

Safari iOS

Full support 7

Samsung Internet Android

Full support Yes

Legend

Full support  
Full support
No support  
No support


See also