[whatwg] Maxlength attribute on input[type=number]

Tab Atkins Jr. jackalmage at gmail.com
Thu Jun 27 15:57:48 PDT 2013

On Thu, Jun 27, 2013 at 3:18 PM, Steve Hoeksema <steve at kotiri.com> wrote:
> In my specific case, a numeric code with a maximum length.
> Say it's 4 digits, and I'm using Chrome. I can put max=9999, but the browser still allows me to type 12345. It won't allow me to submit the form, and it highlights it as an error, but I can still enter it. Using a maxlength means I can't even enter 12345, and it's obvious that it will only accept 4 digits.
> Using input[type=text] is not desirable because (e.g.) it pops up a alphabetical keyboard on iOS instead of a numeric keyboard.
> I can of course restrict the length on input[type=number] with javascript, but if the browser supported it natively that would be far better.

Numeric codes are almost certainly actually type=text, with a
pattern="\d+" or the like.  If the first digit is allowed to be 0,
it's not type=number.  Note that we have the inputmode attribute
to still indicate that the on-screen keyboard should be numeric rather
than alphabetic.


More information about the whatwg mailing list