The Constraint Validation API
Native form validation is great, but at times you may want to do more with it by perhaps adding some custom validation or creating your own error-reporting framework. The Constraint Validation API has a series of objects, properties, and methods aimed at giving you the flexibility to extend the browser’s validation system or to roll your own.
The first property is willValidate, which returns true or false if the element it’s called on will be validated—not if its value is valid, but if the validation process will be applied. You might find it more useful to think of the property as willBeValidated. By default, all form elements return true, unless they are explicitly set not to—for example, by using the disabled ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access