WebAIM - Web Accessibility In Mind

E-mail List Archives

Re: Submitting forms via javascript: Button vs. link vs. other?

for

From: Rowan @ Jetboy
Date: Dec 4, 2009 12:24PM


Definitely <input> or <button> elements. I'd suggest <input type="image"...
for a graphical submit button. I'm not aware of any accessibility issues
with this approach, apart from if the user has images switched off, but this
is something you're going to hit with any image based method, and <input
type="image"... does still work with no images. You could even use
traditional <input type="submit"... elements and use JavaScript to rewrite
them to <input type "image"... ones. Trying to style <input type="submit"...
elements cross-browser is a thankless task.

<snip>

Assuming Javascript is enabled (I know that, itself, can be an
accessibility issue) what are the pros/cons of using various elements
to act as the trigger for submission?

We could use a button, anchor tag, or span.

What I've come up with:

button: pro - it's a form. A button makes sense in the traditional
sense; con - they can be a pain to style

anchor tag : pro - being a link, it makes sense as a 'clickable'
object; Con - submitting a form isn't the same as clicking a link.
Perhaps this is in appropriate and potentially an issue with indexing
spiders and the like.

span (or other neutral element): pro - easy to style and doesn't have
the cons of the above; con - is there one?

Thoughts? Am I overthinking this?

-DA