validityState.badInput - Web APIs 编辑
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 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 compatibility
BCD tables only load in the browser
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论