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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.