WebAIM - Web Accessibility In Mind

E-mail List Archives

Re: Inputs that are Numbers only like Phone zipcode

for

From: Jukka K. Korpela
Date: Aug 14, 2014 12:22PM


2014-08-14 20:34, Nancy Johnson wrote:

> If the field is restricted to numbers only like a phone or zip code.
> From the Accessibility perspective is it better to add a warning in
> the form of label or client-side validation?
>
> Currently the engineers are restricting the field but no warning

I think the important things are:

Does the text before the field (possibly including its label) clearly
state what is expected?

How well does it deal with different types of input? In particular, a
phone input field should accept any spaces and some punctuation and
ignore it, not require it.

How does the page behave when the requirements are not met?

A label should never carry a warning. It should say what is expected,
not what errors may have occurred.

For a phone number, I would primarily use <input type=tel ...> and
possibly use JavaScript checks to check the number.

For a zip code, I would use <input pattern="...">, possibly using
JavaScript to check the input on old browsers.

Yucca