December 2013
Intermediate to advanced
480 pages
14h 11m
English
If you need to add custom validation rules to a form element then you can take advantage of the JavaScript setCustomValidity() method. You can use this method to associate a custom validation error message with a form field.
Imagine, for example, that you have a complex set of rules for validating a username in a user registration form. For example, you want to ensure that the username is a certain length, unique in the database, and does not contain special characters. This is a good candidate for a custom validation.
The following HTML form includes a userName field:
<form> <div> <label> User Name: <input id="userName" required /> </label> ...
Read now
Unlock full access