practiceExperience & interface

Form Validation

Form validation checks whether submitted or entered data meets defined requirements and helps users correct problems without losing valid work.

Download Markdown (.md)

01What it means

Form validation applies syntactic, semantic, and business rules to input. Client-side validation can provide timely feedback, while server-side validation remains authoritative. Effective validation includes prevention, clear identification, specific correction guidance, preserved input, and accessible focus and announcements.[1][2]

Prevention, correction, and authoritative verification Explain constraints early, preserve valid input, and connect errors to recovery
  1. Before inputRequirements, examples, constrained choices
  2. User enters dataAllow enough context to answer
  3. ValidateSyntactic, semantic, business rules
  4. CorrectField message, linked summary, preserved values
  5. Submit safelyServer verifies and confirms outcome

Clear stale errors and return to the affected field when correction is needed

Client-side feedback improves timing; server-side validation remains authoritative.

02Why it matters

Validation protects data quality and system rules, but its user experience determines whether errors become quick corrections or abandonment. Clear recovery reduces repeated effort, support demand, and accidental submission of unintended values.

03When to use it

Validate every meaningful constraint, prioritizing feedback when users can act on it. Validate on submission for cross-field or server-dependent rules, and use inline validation carefully after a field is complete. Do not reject harmless formatting that the system can normalize safely.

04How it works

  1. Define rules from genuine data and business requirements, separating client hints from server authority.
  2. Prevent invalid choices where feasible and explain format or constraints before entry.
  3. Validate at a moment when the user has enough context to correct the value without premature interruption.
  4. Associate each error with its field, preserve valid input, and provide a linked summary for longer forms.
  5. After correction, clear stale errors and verify the submitted value on the server.

05A practical example

Example

A registration form accepts spaces and hyphens in a phone number, normalizes them, and checks account uniqueness on the server. On submission, focus moves to an error summary linking to two invalid fields while all other entries remain intact.

06Where it breaks

Validation cannot guarantee truth, intent, or future validity. Overly strict rules exclude legitimate data, asynchronous checks can race with edits, and feedback shown on every keystroke can create noise and expose incomplete values as errors.

Common mistakes

  • Relying on client-side validation as a security boundary.
  • Clearing the form after an unsuccessful submission.
  • Showing error color without text, association, or correction guidance.
  • Rejecting valid names, addresses, or formats because examples were mistaken for universal rules.

07Sources

  1. Validating InputW3C Web Accessibility Initiative · Accessibility tutorialValidating Input
  2. Error summaryGOV.UK Design System · Institutional design systemError summary
View saved topics

Start typing to search titles, definitions, categories, and frameworks.