Per the spec (http://www.whatwg.org/specs/web-apps/current-work/#constraint-validation-api) a form control's validity.tooLong property should be "true if the element's value is longer than the provided maximum length; false otherwise." However, if you have an input that has a preset value that is greater than its maxlength the tooLong property will still be false: <input id="foo" type="text" maxlength="1" value="AB"> <script> document.getElementById('foo').validity.tooLong; //false </script> Furthermore when this element is in a form that form is allowed to submit - http://jsfiddle.net/tj_vantoll/x5LEn/.
This behavior is correct with respect to the now-current version of the spec. Quoting from https://html.spec.whatwg.org/multipage/forms.html#attr-fe-maxlength : > If an element > (1) has a maximum allowed value length, > (2) **its dirty value flag is true,** > (3) **its value was last changed by a user edit** (as opposed to a change made by a script), > and (4) 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. (Numbering and emphasis mine) In your testcase, the value has never been modified, so the dirty value flag (2) is false, and the user has never edited the value, so (3) isn't satisfied either. Therefore, validity.tooLong should be false, which matches Firefox's current behavior.
Thanks for the reply. It's been long enough that I can't remember whether the spec has changed with regards to this behavior or not. I remember at the time I was investigating why Presto's implementation was different than Gecko's and WebKit's. Your interpretation of the spec seems correct to me, so I'll close this out. Thanks.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 3 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.