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

On Thu, Jun 27, 2013 at 3:18 PM, Steve Hoeksema <steve@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
<http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#input-modalities:-the-inputmode-attribute>
to still indicate that the on-screen keyboard should be numeric rather
than alphabetic.

~TJ

Received on Thursday, 27 June 2013 22:58:34 UTC