Takeshi Tokugawa YD
Takeshi Tokugawa YD

Reputation: 923

Does attribute value "number" of "input" tag is critical for accessibility?

The attribute number of input causes confusing during JavaScript validation and input filtration (discussed here). I am considering to use text attribute value (however with inputmode="numeric") when expect the numeric input from users. I see only one obstacle for now: accessibility. Does text value for numeric input fields impacts on accessibility?

Upvotes: 0

Views: 210

Answers (1)

brennanyoung
brennanyoung

Reputation: 6524

I don't see any special accessibility problems with this approach - as long as the user is adequately informed about any 'bad' input (in line with the WCAG 3.3.x success criteria).

At a minimum, you should direct users to the specific field that has the erroneous input, and preferably give a clue what is wrong with it ("this field must contain only numbers"), rather than just reporting a blanket "this form is not filled out correctly".

Using inputmode="numeric" is a good ergonomic choice, and should prevent bad input from happening in those user agents that handle this attribute correctly.

You'll still have to convert the string to a numerical value later, of course.

Upvotes: 1

Related Questions