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.


<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.");


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

Browser compatibility

ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
badInputChrome Full support 25Edge Full support 14Firefox Full support 29IE No support NoOpera Full support 15Safari Full support 11WebView Android Full support 4.4Chrome Android Full support YesFirefox Android Full support 64Opera Android Full support 14Safari iOS Full support 7Samsung Internet Android Full support Yes


Full support
Full support
No support
No support

See also