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.badInputRead only- Is a
Booleanindicating the user has provided input that the browser is unable to convert. ValidityState.customErrorRead only- Is a
Booleanindicating the element's custom validity message has been set to a non-empty string by calling the element'ssetCustomValidity()method. ValidityState.patternMismatchRead only- Is a
Booleanindicating the value does not match the specifiedpattern. ValidityState.rangeOverflowRead only- Is a
Booleanindicating the value is greater than the maximum specified by themaxattribute. ValidityState.rangeUnderflowRead only- Is a
Booleanindicating the value is less than the minimum specified by theminattribute. ValidityState.stepMismatchRead only- Is a
Booleanindicating the value does not fit the rules determined by thestepattribute (that is, it's not evenly divisible by the step value). ValidityState.tooLongRead only- Is a
Booleanindicating the value exceeds the specifiedmaxlengthforHTMLInputElementorHTMLTextAreaElementobjects. Note: This will never betruein Gecko, because elements' values are prevented from being longer thanmaxlength. ValidityState.tooShortRead only- Is a
Booleanindicating the value fails to meet the specifiedminlengthforHTMLInputElementorHTMLTextAreaElementobjects. ValidityState.typeMismatchRead only- Is a
Booleanindicating the value is not in the required syntax (whentypeisemailorurl). ValidityState.validRead only- Is a
Booleanindicating the element meets all constraint validations, and is therefore considered to be valid. ValidityState.valueMissingRead only- Is a
Booleanindicating the element has arequiredattribute, but no value.
Specifications
| Specification | Status | Comment |
|---|---|---|
| WHATWG HTML Living Standard The definition of 'ValidityState' in that specification. |
Living Standard | Live Standard |
| HTML5.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 WHATWG HTML Living Standard containing this interface. |
Browser compatibility
| Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|---|
| Basic support | (Yes) | (Yes) | (Yes) | 10 | (Yes) | 10.0.3 |
badInput |
? | (Yes) | 29 (29) | ? | ? | 10.0.3 |
| Feature | Android | Chrome for Android | Edge | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|---|
| Basic support | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |
badIndput |
? | ? | 29.0 (29) | ? | ? | ? |
See also
Document Tags and Contributors
Tags:
Contributors to this page:
erikadoyle,
wido,
andreaswachowski,
ianwalter,
Alhadis,
Jeremie,
teoli,
fscholz,
pwdst,
kscarfone,
Rowno,
ethertank,
Sheppy,
jswisher
Last updated by:
erikadoyle,