Forms & data

What is form validation?

Form validation checks whether entered information follows a form's rules, such as required answers, permitted formats and allowed ranges. It identifies entries that need correction before the receiving system accepts them.

By Plainview WebReviewed

The meaning

A rule might require an email address, limit a message's length or accept only a whole number within a stated range. Validation applies those rules to the values supplied. The rules should match what the next step actually needs, rather than reject reasonable variations in names, phone numbers or other information.

Browser validation, also called client-side validation, can show a problem while someone is completing the form. HTML provides common checks, and JavaScript can add more specific behavior. For a form that sends data to a server, the receiving system must check it too: browser checks can be bypassed, and requests can arrive without using the visible form.

Good feedback identifies the affected field and explains how to fix it. Mark required questions before submission, keep useful instructions near the field, and preserve answers that do not need changing. A red border alone does not explain an error.

An example

A fictional workshop inquiry

Email address (required)
Rule: Use an email address format.
Error: Enter an email address, such as name@example.com.

Group size (required)
Rule: Enter a whole number from 1 to 12.
Error: Enter a group size from 1 to 12.

A fictional workshop organizer needs a reply address and an estimated group size. An empty email field or a group size of 20 does not meet the stated rules. The form should explain the correction without clearing the visitor's other answers.

This is a rule specification, not a working booking form. A finished implementation would apply the relevant checks on the receiving server as well as in the browser. Passing these checks would not confirm that a workshop place had been reserved.

When it matters

Agree on each field's requirement, accepted format and error wording before the form is built. Include less obvious cases: a blank optional field, an answer that becomes hidden, a value at the edge of an allowed range and a visitor correcting an earlier mistake. Conditional display and validation need to agree about which answers are relevant.

Plainview's Form & Intake Planner helps describe the questions and handoff for a builder; it does not install server validation or deliver submissions. The HTML Accessibility Checker can inspect supplied markup for common label and naming issues, but testing error recovery in the working form remains a separate step.

A common confusion

Validation is not verification or delivery

An email address can have the right format without existing or belonging to the visitor. Automated spam can also satisfy a form's rules. Address verification, identity checks and spam controls address different questions; validation alone does not provide them.

A valid submission still needs to reach its destination and be handled. A confirmation should describe what actually completed, such as saving an inquiry, rather than imply that an email arrived or a request was approved merely because the fields passed their checks.

Use it in practice

Sources & further reading