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?
Asked
Active
Viewed 61 times
0

Takeshi Tokugawa YD
- 670
- 5
- 40
- 124
1 Answers
1
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.

brennanyoung
- 6,243
- 3
- 26
- 44