Visual Example
Required Form Control
...
Invalid Form Control
...
Acceptance Criteria
As a screen reader and keyboard only user I should:
...
the screen reader should announce that this is an invalid entry
the screen reader should announce what the error is and how to correct the error
...
Markup and Code
Use ARIA to Create Accessible Inline Error Messages
Make inline error messages accessible to screen reader users by using ARIA.
Most screen reader and browser combinations announce a form control as “required” required when using the required “required” attribute.
Prevent screen readers from announcing required form controls as invalid by default (when the form control first receives keyboard focus), by using aria-invalid="false".
Update the aria-invalid attribute to “true” if the current value (or lack of value) of a required control does not pass validation.
Use aria-describedby on required form controls to point to an element that will contain any necessary the inline error messagingmessage on how to resolve the error.
Can’t always rely on browser’s client-side error validation to be accessible.
Create a custom client-side validation script and helpful messaging by suppressing the browser’s default validation message by adding the novalidate attribute to the form element.
...