HTML and CSS Reference
Try it out!
If you load the form in a compatible browser and try to break the custom validation rules
described previously, you'll notice that the custom error message will be displayed to the
user, as illustrated in figure 2.10 .
Figure 2.10. A demonstration of custom validation in action. In this case, the user has entered a valid password (at
least eight characters in length), but they've entered a value in the Confirm Password field that doesn't match the
value in the Password field. This causes the error “Confirm Password must match Password” to be displayed.
Next you'll use the invalid event, which fires any time the user tries to submit a form
with one or more fields that are marked as invalid.