--- url: "https://www.w3.org/WAI/WCAG22/Techniques/aria/ARIA19" titulek: "ARIA19: Using ARIA role=alert or Live Regions to Identify Errors | WAI | W3C" h1: "Technique ARIA19:Using ARIA role=alert or Live Regions to Identify Errors" popis: "" jazyk: "en" kanonicka: "" drobecky: [] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-14 06:29:19" znaku: 4463 slov: 580 kodovani: "utf-8" sha256: "0078fe29ffaf511f044a5ef3b1a437224435226921583023f0ec8e3ab1d758ae" --- # Technique ARIA19:Using ARIA `role=alert` or Live Regions to Identify Errors ## About this Technique This technique relates to: - [3.3.1 Error Identification](https://www.w3.org/WAI/WCAG22/Understanding/error-identification) ( **Sufficient** ) - [4.1.3 Status Messages](https://www.w3.org/WAI/WCAG22/Understanding/status-messages) ( **Sufficient** using a more specific technique) This technique applies to technologies that support [Accessible Rich Internet Applications (WAI-ARIA)](https://www.w3.org/TR/wai-aria/). Techniques are examples of ways to meet Web Content Accessibility Guidelines (WCAG). They are **not required** to meet WCAG. Content can satisfy the normative requirements of WCAG even if it does not use any of the documented techniques. See [About WCAG Techniques](https://www.w3.org/WAI/WCAG22/Techniques/about). ## Description The purpose of this technique is to notify Assistive Technologies (AT) when an input error occurs. The `aria-live` attribute makes it possible for an AT (such as a screen reader) to be notified when error messages are injected into a Live Region container. The content within the `aria-live` region is automatically read by the AT, without the AT having to focus on the place where the text is displayed. There are also a number of [special case live region roles](https://www.w3.org/TR/wai-aria/#live_region_roles) which can be used instead of applying live region properties directly. ## Examples ### Example 1: Injecting error messages into a container with role=alert already present in the DOM The following example uses role=alert which is equivalent to using `aria-live=assertive`. In the example there is an empty error message container element with `aria-atomic=true` and an aria-live property or alert role present in the DOM on page load. The error container must be present in the DOM on page load for the error message to be spoken by most screen readers. `aria-atomic=true` is necessary to make Voiceover on iOS read the error messages after more than one invalid submission. JavaScript is used to test if the inputs are empty on submit and inject error messages into the live region containers if so. Each time a new submit is attempted the previous error messages are removed from the container and new error messages injected. ``` const form = document.getElementById('signup'); form.addEventListener('submit', function(event) { event.preventDefault(); const firstNameInput = document.getElementById('first'); const lastNameInput = document.getElementById('last'); const emailInput = document.getElementById('email'); const errorsContainer = document.getElementById('errors'); const errorMessages = []; if (firstNameInput.value === '') { errorMessages.push('