W3cubDocs

/DOM

ValidityState.badInput

The read-only property ValidityState.badInput 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 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.
HTML5
The definition of 'ValidityState.badInput' in that specification.
Recommendation First snapshot of HTML Living Standard containing this interface.

Browser compatibilityUpdate compatibility data on GitHub

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
Basic support ? ? 29 No ? ?
Mobile
Android webview Chrome for Android Edge Mobile Firefox for Android Opera for Android iOS Safari Samsung Internet
Basic support ? ? ? 29 ? ? ?

See also

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/ValidityState/badInput