WebAIM - Web Accessibility In Mind

E-mail List Archives

Re: Focus for error messages


From: Jared Smith
Date: Apr 19, 2007 8:40AM

On 4/19/07, Karl Groves wrote:

> Does anyone have any good examples of methods to supply error messages as
> they occur that are accessible?

We implemented a method that seems to work pretty well. It doesn't do
it 'live', but after the form is submitted. You can try it out at
http://webaim.org/contact/ (just leave a field blank, no worries if
you accidentally send a message). It uses javascript to visually
highlight the error messages as well as set focus directly to the
error message. Links then provide direct access to the relevant form
fields, also with visual highlighting and focus set. It works well,
even with javascript disabled.

If anyone has feedback about this approach, please post it. I'm
working on packaging up the script and PHP code for others to use, but
want to make sure it works correctly.

Jared Smith