Why doesn't the HTML 5 specification for the input type="number" control include support for the maxlength
attribute?
Browsing Stack Overflow for questions matching search terms like input type number maxlength, it seems that there are quite a few web applications out there with a requirement to display a control that requires the user to input a number, but also constrains the input field to a particular maximum number of characters.
Judging from the Stack Overflow answers to these questions, it seems like the solution that most applications end up landing on is either using some manner of Javascript "hack" to limit the count of characters appearing in the control, or else to use a input type="text"
control (with its longstanding support for the maxlength
attribute) instead of the newer input type="number"
.
It seems like a cleaner solution for this common requirement would be to allow maxlength
to work with input type="number"
controls.
I understand that a particular max
attribute value may not always correspond directly to a maxlength
attribute value -- e.g. if the maximum number to be allowed in a control is something like 50
instead of 99
-- but apart from that, what is the reason that the HTML 5 specification does not include support for the maxlength
attribute?