Frage

Possibly related: WAI ARIA alert on form submit (with page reloading)

On a simple HTML form that submits to the server (no JavaScript)... if there are one or more errors, and the page is re-displayed with the same form, and a <ul> of error messages, should that list be marked up as:

<form ...>
    <ul role="alert">
        <li>Error 1</li>
        <li>Error 2</li>
    </ul>
    <!-- Fields -->
</form>

The reason I ask is because "elements with the role alert have an implicit aria-live value of assertive"... which makes me think that perhaps this is more for JavaScript inserting the errors into the DOM.

https://www.w3.org/TR/wai-aria/roles#alert

So this might not be any use for assistive devices (as its on the page to begin with)... and could possibly be harmful, as its not "live".

https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_alert_role

War es hilfreich?

Lösung

I would say you are right. Live regions are to show changing information on screen, hence "live". If there was AJAX, there would be a good case for an alert to say what went wrong. However, with a full post back to the server, I'd say it wouldn't be effective here.

I just tried this with NVDA on Firefox, it does (surprisingly) read the alert out as soon as the page is opened. However, you need to decide if this is the functionality you'd be going for.

Hope this helps.

Andere Tipps

As per the latest request I received from SSB Bart report, they are asking us to add role="alert" to each error message.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top