The ValidityState interface represents the validity states that an element can be in, with respect to constraint validation. Together, they help explain why an element's value fails to validate, if it's not valid.

Properties

For each of these Boolean properties, a value of true indicates that the specified reason validation may have failed is true, with the exception of the valid property, which is true if the element's value obeys all constraints.

ValidityState.badInput Read only
Is a Boolean indicating the user has provided input that the browser is unable to convert.
ValidityState.customError Read only
Is a Boolean indicating the element's custom validity message has been set to a non-empty string by calling the element's setCustomValidity() method.
ValidityState.patternMismatch Read only
Is a Boolean indicating the value does not match the specified pattern.
ValidityState.rangeOverflow Read only
Is a Boolean indicating the value is greater than the maximum specified by the max attribute.
ValidityState.rangeUnderflow Read only
Is a Boolean indicating the value is less than the minimum specified by the min attribute.
ValidityState.stepMismatch Read only
Is a Boolean indicating the value does not fit the rules determined by the step attribute (that is, it's not evenly divisible by the step value).
ValidityState.tooLong Read only
Is a Boolean indicating the value exceeds the specified maxlength for HTMLInputElement or HTMLTextAreaElement objects. Note: This will never be true in Gecko, because elements' values are prevented from being longer than maxlength.
ValidityState.tooShort Read only
Is a Boolean indicating the value fails to meet the specified minlength for HTMLInputElement or HTMLTextAreaElement objects.
ValidityState.typeMismatch Read only
Is a Boolean indicating the value is not in the required syntax (when type is email or url).
ValidityState.valid Read only
Is a Boolean indicating the element meets all constraint validations, and is therefore considered to be valid.
ValidityState.valueMissing Read only
Is a Boolean indicating the element has a required attribute, but no value.

Specifications

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

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic supportChrome Full support YesEdge Full support YesFirefox Full support YesIE Full support 10Opera Full support YesSafari Full support 11WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android ?
badInputChrome ? Edge ? Firefox Full support 29IE No support NoOpera ? Safari ? WebView Android ? Chrome Android ? Edge Mobile ? Firefox Android Full support 29Opera Android ? Safari iOS ? Samsung Internet Android ?
tooLongChrome ? Edge Full support YesFirefox ? IE Full support 10Opera ? Safari ? WebView Android ? Chrome Android ? Edge Mobile Full support YesFirefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android ?

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown

See also

Document Tags and Contributors

Last updated by: sideshowbarker,