Technique ARIA18:Using aria-alertdialog to Identify Errors
About this Technique
This technique relates to:
- 3.3.1: Error Identification (Sufficient)
- 3.3.3: Error Suggestion (Sufficient)
- 4.1.3: Status Messages (Advisory)
This technique applies to technologies that support Accessible Rich Internet Applications (WAI-ARIA).
Description
The purpose of this technique is to alert people that an input error has occurred. Using role="alertdialog" creates a notification. This notification should be modal with the following characteristics:
aria-labeloraria-labelledbyattribute gives the alertdialog an accessible name.- The
alertdialogcontains at least one focusable element, and the focus should move to that element when thealertdialogopens. - The tab order is constrained within the
alertdialogwhilst it is open. - When the
alertdialogis dismissed, the focus moves back to the position it had before thealertdialogopened, if possible.
Note that the alertdialog should not be present in a way that it will be accessed by assistive technology until it is needed. One way to do this is not to include it in the static HTML and instead to insert it into the DOM via script when the error condition is triggered. The insertion would correspond to the following HTML sample.
Examples
Example 1: Alert dialog
This example shows how a notification using role="alertdialog" can be used to notify someone they have entered invalid information.
<div role="alertdialog" aria-labelledby="alertHeading">
<h1 id="alertHeading">Error</h1>
<p>Employee's Birth Date is after their hire date.
Please verify the birth date and hire date.</p>
<button>Save and Continue</button>
<button>Return to page and correct error</button>
</div>
Working example: Alert dialog.
Related Resources
No endorsement implied.
Tests
Procedure
- Trigger the error that causes the
alertdialogto appear. - Determine that the
alertdialogcontains at least one focusable element, and the focus moves to that element when thealertdialogopens. - Determine that the tab order is constrained within the
alertdialogwhile it is open, and when thealertdialogis dismissed, the focus moves back to the position it had before thealertdialogopened, if possible. - Examine the element with
alertdialogapplied. - Determine that either the
aria-labeloraria-labelledbyattribute has been correctly used to give the alertdialog an accessible name. - Determine that the contents of the
alertdialogidentifies the input error. - Determine whether contents of the
alertdialogsuggests how to fix the error.
Expected Results
- Checks #2, #3, #5 and #6 are true. For Success Criterion 3.3.3, check #7 is also true.