Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make maxlength attribute accessible?

I have a form in a few input fields. For one of the input field I have a length validation, for which I have used maxlength="20".

The issue here is that the JAWS users don't come to know that the max length has been reached in the input field, as JAWS continues to keep on reading the key they press on their keyboard.

Is there a way to make this accessible?

Regards, Zeeshan

like image 938
Zeeshan Rang Avatar asked Jun 04 '14 11:06

Zeeshan Rang


1 Answers

Three approaches, not mutually exclusive:

  1. Include a statement about maximum number of characters before the element.
  2. Implement a JavaScript-driven check on the number of characters when leaving the element.
  3. Implement a JavaScript-driven check that is triggered by any input event on the element and that checks the number of characters on the fly.

Method 1 is simplest, but it might be too disturbing if we expect that in the vast majority of cases, the length is not an issue. Method 3 takes more programming effort than method 2 but provides for better accessibility: the user gets a message as soon as he tries to exceed the limit.

As @Quentin comments, this is really something that should be handled by JAWS. The maxlength attribute for input has been in HTML as long as it has had the element, from HTML 2.0 (1995), so there is little excuse for not having implemented it. I cannot check whether JAWS actually supports it, so I have written my answer assuming that it does not.

like image 94
Jukka K. Korpela Avatar answered Oct 02 '22 19:10

Jukka K. Korpela