HTML and CSS Reference
custom error messages by providing a setCustomValidity method and a valida-
tionMessage property. Both constructs allow the application to assign an error message
to the <input> element's validationMessage attribute. Determining which con-
struct to use will depend on the browser's support for setCustomValidity .
Step 1: Add custom validation and error messages to input fields
The order form example will perform custom validation for a number of tests using the
• Full Name must be at least four characters long.
• Password must be at least eight characters long.
• Password and Confirm Password must match.
• Name on Card must be at least four characters long.
Let's add this custom validation to the app.js file. Add the code from this listing to the end
of the init function, directly after the call to qtyListeners .
Listing 2.11. app.js—Performing custom validation