Chrome is ignoring maxlength field on input type=number

Skip to first unread message

Eric Meysenburg

unread,
Oct 30, 2014, 1:01:31 PM10/30/14
to chromi...@chromium.org
I have a standard input field of type=number in an HTML5 document. In testing, it was noticed that the field allowed any length of number to be entered... but it only happened in Chrome. Firefox, Safari, and IE all adhered to the maxlength rule. 

<input type="number" id="zipcode" name="zipcode" value="" maxlength="5">

I have tried adding pattern="[0-9]*"pattern="[0-9]{5}", pattern="\d{5}" with no effect.
I have tested in desktop Chrome for Win7 (version 38.0.2125.111) and the mobile version of chrome (version 38.0.2125.102)

I would call this a bug since the HTML 5 specifications do not indicate to ignore maxlength for any type of input field.

From the HTML 5.1 nightly page.
http://www.w3.org/html/wg/drafts/html/master/single-page.html#attr-fe-maxlength



4.10.19.3 Limiting user input length: the maxlength attribute

A form control maxlength attribute, controlled by a dirty value flag, declares a limit on the number of characters a user can input.

If an element has its form control maxlength attribute specified, the attribute's value must be a valid non-negative integer. If the attribute is specified and applying the rules for parsing non-negative integers to its value results in a number, then that number is the element's maximum allowed value length. If the attribute is omitted or parsing its value results in an error, then there is no maximum allowed value length.

Constraint validation: If an element has a maximum allowed value length, its dirty value flag is true, its value was last changed by a user edit (as opposed to a change made by a script), and the code-unit length of the element's value is greater than the element's maximum allowed value length, then the element is suffering from being too long.

User agents may prevent the user from causing the element's value to be set to a value whose code-unit length is greater than the element's maximum allowed value length.

PhistucK

unread,
Oct 30, 2014, 1:53:54 PM10/30/14
to Eric Meysenburg, Chromium Apps
That is the general constraints.
But every input type has its own specific constraints.
Specifically, under "Bookkeeping details" -
"The following content attributes must not be specified and do not apply to the element: accept, alt, checked, dirname, formaction, formenctype, formmethod, formnovalidate, formtarget, height, inputmode, maxlength, minlength, multiple, pattern, size, src, and width."


PhistucK

--
You received this message because you are subscribed to the Google Groups "Chromium Apps" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-app...@chromium.org.
To post to this group, send email to chromi...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/chromium-apps/.
For more options, visit https://groups.google.com/a/chromium.org/d/optout.

Reply all
Reply to author
Forward
0 new messages