Performing client-side validation
Client-side validation checks form values before the form is submitted, which can provide immediate feedback to the user. Client-side validation is used in addition to server-side validation, which is still required because users may disable the client-side JavaScript code or manually submit form data.
Understanding the Built-in HTML Client validation features
HTML supports validation attributes on input elements, along with a JavaScript API that allows validation events to be received, both of which are described at https://developer.mozilla.org/en-US/docs/Learn/Forms/Form_validation. These features can be useful, but they are not always implemented consistently and provide only basic validation checks. It requires only a little more work to create a more comprehensive validation system, which is why they are not used in this chapter.
The key to client-side development is consistency. This can be achieved by using the same...