Skip to main content

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.

MDN Reference

Properties

badInput

readonly badInput: boolean;

The read-only badInput property of the ValidityState interface 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.

MDN Reference


customError

readonly customError: boolean;

The read-only customError property of the ValidityState interface returns true if an element doesn't meet the validation required in the custom validity set by the element's setCustomValidity() method.

MDN Reference


patternMismatch

readonly patternMismatch: boolean;

The read-only patternMismatch property of the ValidityState interface indicates if the value of an <input>, after having been edited by the user, does not conform to the constraints set by the element's pattern attribute.

MDN Reference


rangeOverflow

readonly rangeOverflow: boolean;

The read-only rangeOverflow property of the ValidityState interface indicates if the value of an <input>, after having been edited by the user, does not conform to the constraints set by the element's max attribute.

MDN Reference


rangeUnderflow

readonly rangeUnderflow: boolean;

The read-only rangeUnderflow property of the ValidityState interface indicates if the value of an <input>, after having been edited by the user, does not conform to the constraints set by the element's min attribute.

MDN Reference


stepMismatch

readonly stepMismatch: boolean;

The read-only stepMismatch property of the ValidityState interface indicates if the value of an <input>, after having been edited by the user, does not conform to the constraints set by the element's step attribute.

MDN Reference


tooLong

readonly tooLong: boolean;

The read-only tooLong property of the ValidityState interface indicates if the value of an <input> or <textarea>, after having been edited by the user, exceeds the maximum code-unit length established by the element's maxlength attribute.

MDN Reference


tooShort

readonly tooShort: boolean;

The read-only tooShort property of the ValidityState interface indicates if the value of an <input>, <button>, <select>, <output>, <fieldset> or <textarea>, after having been edited by the user, is less than the minimum code-unit length established by the element's minlength attribute.

MDN Reference


typeMismatch

readonly typeMismatch: boolean;

The read-only typeMismatch property of the ValidityState interface indicates if the value of an <input>, after having been edited by the user, does not conform to the constraints set by the element's type attribute.

MDN Reference


valid

readonly valid: boolean;

The read-only valid property of the ValidityState interface indicates if the value of an <input> element meets all its validation constraints, and is therefore considered to be valid.

MDN Reference


valueMissing

readonly valueMissing: boolean;

The read-only valueMissing property of the ValidityState interface indicates if a required control, such as an <input>, <select>, or <textarea>, has an empty value.

MDN Reference