WebAIM - Web Accessibility In Mind

E-mail List Archives

Re: A simple beginner's question

for

From: Léonie Watson
Date: May 23, 2016 1:53AM


> From: Alexander Karelas [mailto: <EMAIL REMOVED> ]
> Sent: 22 May 2016 21:32
> When a submitted form contains errors and re-appears to the user together
> with the error messages, I need some way to co-relate each error message
> with a text field. For this, I had thought of using the aria-describedby
> property. Am I wrong? I read somewhere that I could do that. if I don't use
> this aria attribute, as you say that I don't have to, then how am I going to
> relate the error message to the field, so that my user will know?

You could use aria-describedby, yes. You don't need to though. You could just insert the error message into the <label> for the field that has the problem:

<label>Email
<input type="email">
<span class="error">You must enter an email address</span>
</label>

ARIA is designed to provide semantic information when it isn't available in the host language, in this case in HTML. That doesn't mean you shouldn't use ARIA, but generally speaking if you can do something in HTML without ARIA, that's the best bet.

Léonie.

--
@LeonieWatson tink.uk Carpe diem