liveBook · Manning

Aria-invalid

As explained in Architecting Accessibility

aria-invalid is an ARIA attribute that communicates that an element's entered value does not conform to the expected format or constraints.

When a form rejects an entry, aria-invalid communicates the field’s error state to assistive technologies. Set aria-invalid="true" on each invalid field, and provide a visible message explaining the problem and how to fix it. Do not rely on color alone to identify errors. section 6.1.10 section 6.1.6

Associate the field with its error message using aria-describedby. When the user corrects an error, update aria-invalid and the associated message. For multiple errors, provide a summary linking to the affected fields and move focus to the summary or first invalid field. section 6.1.6 section 6.1.10

<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

An email field marked invalid and associated with a specific format-error message. section 6.1.6

How Architecting Accessibility covers it

How deep it goes
Shows field-level markup and recovery patterns, including updating the state and message after correction.
Examples
Uses an email field with a format error and a form submission summary linking to invalid fields.
What you can do after
Apply it via ARIA by marking invalid fields and associating them with corrective error messages.
How it connects
Connects form validation with aria-describedby, error messages, error summaries, and the Constraint Validation API.

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.