Accessibility

a11y/form-errors

An input error is shown in text next to the field, tied to it with aria-describedby, and says how to fix it.

seriousmanualWCAG 3.3.1, 3.3.3, 4.1.3 · AAfe-a11y-forms

Why

An error shown only by a red border is invisible to screen reader users and to people who cannot tell the colour apart; an error far from its field, or one that says only "invalid", leaves everyone guessing.

Fix

On a failed submit: set aria-invalid="true" on each wrong field, render the message in text right after it with an id, point to it with aria-describedby, and say what to do ("Enter a date like 31/12/2026"). Move focus to the first wrong field, or to an error summary at the top that links to each field. Keep the values the person typed.

Examples

<!-- good -->
<label for="email">Email</label>
<input id="email" type="email" autocomplete="email" aria-invalid="true" aria-describedby="email-error">
<p id="email-error">Enter an email address like name@example.com.</p>

Sources

Facts

Id
a11y/form-errors
Severity
serious
Check
manual a person reviews it; the report lists it as a checklist
Applies to
html angular vue svelte astro jsx
WCAG 2.2
3.3.1, 3.3.3, 4.1.3, level AA
Taught by the skill
fe-a11y-forms Accessible forms
Since version
0.1.0

Rule file on GitHub

Read it in the terminal

npx github:dawidolko/frontend-skills explain a11y/form-errors