WebAIM - Web Accessibility In Mind

E-mail List Archives

Re: ARIA Attributes

for

From: Birkir R. Gunnarsson
Date: Aug 22, 2016 6:21PM


You cannot use aria-labelledby for error messages.
aria-labelledby is used to connect a form field with an element
containing its label (it is always preferable to use the html label
element, either wrapped around the form field and the text or with a
for attribute whose ID matches the ID of the input field).
This gets mapped to the elements accessible name.
It is supposed to be short and descriptive.
<span id="lbl">Please enter your name</label>
<input type="text" aria-labelledby="lbl">

aria-describedby is supposed to be used for instructions of further
information, including (for the moment) error messages.
<span id="lbl">Please enter your name</label>
<span id="instr">Can only contain white space and characters, cannot
exceed 40 characters.</span>
<input type="text" aria-labelledby="lbl" aria-describedby="instr">

You can also provide the accessible description through the title attribute
<input type="text" aria-labelledby="lbl" title="Can only contain white
space and characters must not exceed 40 characters">
(in fact, if there is no other source for the accessible name, the
value of the title attribute, if present, is used).

For error messages you need to use aria-describedby.
If it already has a reference to the instructions, you put the ID of
the error message string before the ID of the instructions.
<span id="lbl">Please enter your name</label>
<span id="instr">Can only contain white space and characters, cannot
exceed 40 characters.</span>
<input type="text" aria-labelledby="lbl" aria-describedby="errMsg, instr">
<span id="errMsg">Error: name must not be empty.</span>


ARIA 1.1 is defining a different way to reference error messages, but
the spec is not finalized yet, and there is little or no support for
it in the user agents.
Cheers
-B







On 8/22/16, Jim Homme < <EMAIL REMOVED> > wrote:
> Hi Jamous,
> I think you can use ID.
>
> Jim
>
>
> =========> Jim Homme,
> Accessibility Consultant,
> Bender HighTest Accessibility Team
> Bender Consulting Services, Inc.,
> 412-787-8567,
> <EMAIL REMOVED>
> http://www.benderconsult.com/our%20services/hightest-accessible-technology-solutions
> E+R=O
>
>