Constraint Validation API

The most robust way to validate a form field in the browser is to write a validation function. You can use validation functions in conjunction with the Constraint Validation API to trigger built-in validation behavior.

But there is a catch, and it is not a small one: The Constraint Validation API has poor support in Apple’s Safari browser.

Despite this oversight, it is important to write code that targets standard behavior and then add a JavaScript library that adds support for noncompliant browsers. (You can read more about this in the section called For the More Curious: The Webshims Library at the end of this chapter.)

Suppose your coffee truck is only for employees of your company, so you want to make ...

Get Front-End Web Development: The Big Nerd Ranch Guide 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.