aria-invalid
TokenIndicates that the value the user entered fails validation or doesn't match the expected format. Values include true, false, grammar, and spelling, and it's usually toggled after the user submits or leaves the field. Pair it with aria-errormessage or aria-describedby so screen-reader users hear what went wrong and how to fix it.
Values
- false (default)
- The value is valid.
- true
- The value has failed validation.
- grammar
- A grammatical error was detected.
- spelling
- A spelling error was detected.
Used on
Any HTML element —
aria-invalid is a global property.Associated roles
Every ARIA role. As a global property,
aria-invalid is supported on all roles.Example
aria-invalid="…"
<input aria-invalid="true" aria-errormessage="err" />
<p id="err">Enter a valid email.</p>References