Client-Side Validation
Validate input before sending it anywhere.
Why Validate on the Client
Client-side validation gives instant feedback and a smoother experience. Remember it is a convenience, not security: always validate on the server too.
Validating on Submit
A common pattern checks fields when the form is submitted, canceling submission if anything is invalid.
form.addEventListener("submit", (e) => {
if (!isValid()) {
e.preventDefault();
}
});All lessons in this course
- Reading Input Values
- The submit Event
- Client-Side Validation
- The Constraint Validation API