web api interface
ValidityState
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.
Instance properties
Each validity state is represented by a Boolean property. A value of true indicates that the corresponding validation constraint has failed, except for the valid property, which is true when the element’s value obeys all constraints.
badInputRead only- : A boolean value that is
trueif the user has provided input that the browser is unable to convert.
- : A boolean value that is
customErrorRead only- : A boolean value indicating whether the element’s custom validity message has been set to a non-empty string by calling the element’s
setCustomValidity()method.
- : A boolean value indicating whether the element’s custom validity message has been set to a non-empty string by calling the element’s
patternMismatchRead onlyrangeOverflowRead only- : A boolean value that is
trueif the value is greater than the maximum specified by themaxattribute, orfalseif it is less than or equal to the maximum. Iftrue, the element matches the:invalidand:out-of-rangeand CSS pseudo-classes.
- : A boolean value that is
rangeUnderflowRead only- : A boolean value that is
trueif the value is less than the minimum specified by theminattribute, orfalseif it is greater than or equal to the minimum. Iftrue, the element matches the:invalidand:out-of-rangeCSS pseudo-classes.
- : A boolean value that is
stepMismatchRead onlytooLongRead only- : A boolean value that is
trueif the value exceeds the specifiedmaxlengthforHTMLInputElementorHTMLTextAreaElementobjects, orfalseif its length is less than or equal to the maximum length. Note: This property is nevertruein Gecko, because elements’ values are prevented from being longer thanmaxlength. Iftrue, the element matches the:invalidand:out-of-rangeCSS pseudo-classes.
- : A boolean value that is
tooShortRead only- : A boolean value that is
trueif the value fails to meet the specifiedminlengthforHTMLInputElementorHTMLTextAreaElementobjects, orfalseif its length is greater than or equal to the minimum length. Iftrue, the element matches the:invalidand:out-of-rangeCSS pseudo-classes.
- : A boolean value that is
typeMismatchRead onlyvalidRead onlyvalueMissingRead only
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.