DOM Properties
ValidityState.badInput
True when the browser cannot convert user-entered text to the control’s value type. Invalid script assignments may instead be sanitized to an empty string. The example shows sanitization, not a native typing error. Example result: false.
Formal Syntax & Structure
html syntaxhtml
input.validity.badInputReturn Value
boolean
Read-only constraint flag.
Working Example
Example Snippethtml
<input type="number" aria-label="Quantity"><p> Result: <output id="result"></output></p><script> const result = document.getElementById("result"); (async () => { const input = document.querySelector("input"); input.value = "abc"; result.textContent = input.validity.badInput; })().catch(error => { result.textContent = "Error: " + error.name; });</script>