Form Element maxlength & minlength don't create a character range
Reported by
derek.p....@gmail.com,
May 23 2016
|
||
Issue description
UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:46.0) Gecko/20100101 Firefox/46.0
Example URL:
Steps to reproduce the problem:
1. Create a form input element
2. Set minlength="6" maxlength="20" oninvalid="setCustomValidity('Please enter between 6 and 20 characters.')"
3. setCustomValidity() will pop the error message in all cases, regardless of the length of the string being within the specified range
What is the expected behavior?
setCustomValidity() should only pop the error message when the length of the string is less than 6 characters
What went wrong?
minlength & maxlength SHOULD work together so as to form a character length range (as per spec)!
See the "Name of Event" example here: https://html.spec.whatwg.org/multipage/forms.html#attr-fe-minlength
Does it occur on multiple sites: Yes
Is it a problem with a plugin? No
Did this work before? No
Does this work in other browsers? No Firefox 46.0.1
Chrome version: 50.0.2661.94 (Official Build) (64-bit) Channel: stable
OS Version: OS X 10.11
Flash Version: Shockwave Flash 21.0 r0
I've reported similar issues to WebKit & Mozilla:
https://bugs.webkit.org/show_bug.cgi?id=149832
https://bugzilla.mozilla.org/show_bug.cgi?id=932755
,
May 23 2016
You appear to be using setCustomValidity() incorrectly. As its name suggests, calling it actually affects the validity of the input. It can mark an otherwise-valid input as invalid. It doesn't just display the error message bubble. Calling setCustomValidity() with a non-empty string argument sets input.validity.customError to true , thus marking the input as invalid. validity.customError doesn't get reset automatically. You must later call setCustomValidity() with an empty string to reset the custom validity back to being valid. Replace `setCustomValidity` with `alert` in your example and you'll see what I mean.
,
May 23 2016
As cvrebert wrote, this is an expected behavior. |
||
►
Sign in to add a comment |
||
Comment 1 by thestig@chromium.org
, May 23 2016