Name

FormValidity — the validity of a form control

Synopsis

The validity property of a FormControl refers to a FormValidity object that is a live representation of the validity state of that control. If the valid property is false, the control is not valid, and at least one of the other properties will be true to indicate the nature of the validity error (or errors).

Form validation is an HTML5 feature that, at the time of this writing, is not yet widely implemented.

Properties

readonly boolean customError

A script called FormControl.setCustomValidity() on this element.

readonly boolean patternMismatch

The input does not match the pattern regular expression.

readonly boolean rangeOverflow

The input is too large.

readonly boolean rangeUnderflow

The input is too small.

readonly boolean stepMismatch

The input does not match the specified step.

readonly boolean tooLong

The input is too long.

readonly boolean typeMismatch

The input is of the wrong type.

readonly boolean valid

If this property is true, the form control is valid, and all the other properties are false. If this property is false, the form control is not valid, and at least one of the other properties is true.

readonly boolean valueMissing

The form element was required, but no value was entered.

Get JavaScript: The Definitive Guide, 6th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.