Dostępność

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.

poważnaręczneWCAG 3.3.1, 3.3.3, 4.1.3 · AAfe-a11y-forms

Dlaczego

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.

Poprawka

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.

Przykłady

<!-- 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>

Źródła

Fakty

Identyfikator
a11y/form-errors
Waga
poważna
Sprawdzanie
ręczne ocenia człowiek; raport podaje to jako listę kontrolną
Dotyczy plików
html angular vue svelte astro jsx
WCAG 2.2
3.3.1, 3.3.3, 4.1.3, poziom AA
Uczy jej skill
fe-a11y-forms Accessible forms
Od wersji
0.1.0

Plik reguły na GitHubie

Przeczytaj w terminalu

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