Bug 99115
Summary: | Constraint Validation API tooLong property incorrect with prefilled value | ||
---|---|---|---|
Product: | WebKit | Reporter: | TJ VanToll <tj.vantoll> |
Component: | Forms | Assignee: | Nobody <webkit-unassigned> |
Status: | RESOLVED WONTFIX | ||
Severity: | Normal | CC: | tkent |
Priority: | P2 | ||
Version: | 528+ (Nightly build) | ||
Hardware: | Mac | ||
OS: | OS X 10.8 |
TJ VanToll
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/.
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Kent Tamura
(In reply to comment #0)
> 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."
Don't forget that green boxes are non-normative. We need to refer to other places for normative definition.
See http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#limiting-user-input-length:-the-maxlength-attribute
> 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.
The input element is not dirty and not user-edited in this case.