liveBook · Manning

Client-side validation

As explained in Architecting Accessibility

Client-side validation is checking form data in software running on the user's device before it is submitted to a server.

Client-side validation checks form data before submission, helping users catch mistakes and reducing unnecessary or potentially unsafe requests. It does not replace server-side validation, which remains essential. section 6.1.6 section 6.7

Use browser features first, then add guidance where users need it:

  • Use native HTML attributes such as required, type, and pattern for built-in constraints and submission blocking. section 6.1.6
  • Make errors clear and actionable: identify the problem and explain how to fix it, such as showing the expected email format. section 6.1.6
  • For more specific messages, combine native constraints with JavaScript’s Constraint Validation API. Native messages may be insufficient for complex fields, and long forms can require repeated submissions to find errors. section 6.1.6
<label for="email">Owner’s Email</label>
<p id="email-error">Error: Enter the email address in the format name@example.com.</p> #A
<input 
  id="email" 
  name="email" 
  type="email" 
  aria-invalid="true" #B
  aria-describedby="email-error"> #C

Pair an email input with an error that states the expected format and is programmatically associated with the field. section 6.1.6

How Architecting Accessibility covers it

How deep it goes
Explains native constraints, browser behavior, error guidance, and JavaScript customization, while retaining server-side validation as essential.
Examples
Uses required, type, and pattern attributes, an email-format correction message, and setCustomValidity().
What you can do after
Apply native HTML constraints and add specific JavaScript error messages while preserving server-side checks.
How it connects
Connects native HTML validation with server-side validation and the Constraint Validation API.

Also explained in

Compare how 8 books explain client-side validation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Architecting Accessibility. The section links point to the parts of the book it draws on.