Form
Errors
Published on
Description
Form errors communicate validation failures to users. Errors should be associated with their fields programmatically and announced to screen readers via live regions.
Avoid relying on browser default validation — it has significant accessibility and usability gaps.
Example
Accessibility
- Use
aria-describedbylinking fields to their error messages. It has more reliable cross-platform support thanaria-errormessage. - Set
aria-invalid="true"only after a validation attempt — never on initial page load. - Error messages should use
aria-live="polite"(notassertive) to preserve field name announcements. - Error IDs follow the pattern
{id}-error. Hint IDs follow{id}-hint. Buildaria-describedbyfrom both. - Avoid default browser validation — error messages disappear, don't scale with zoom, and lack context. Use
novalidateon forms.
References
- Exposing Field Errors (opens in new tab) — Adrian Roselli
- Avoid Default Field Validation (opens in new tab) — Adrian Roselli
- Live Region Support (opens in new tab) — Adrian Roselli
Related
- Alert — for page-level error summaries
Variables
None for form errors