User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:25.0) Gecko/20100101 Firefox/25.0 (Beta/Release) Build ID: 20131025150754 Steps to reproduce: HTML (5.1) now specifies a minlength Attribute and validityState.tooShort property. Would be nice, if this is implemented: http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#attr-fe-minlength http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#suffering-from-being-too-short
Created attachment 8411408 [details] [diff] [review] WIP 1 - Implementation This seems like a reasonable request to me (as someone not on the DOM team) and I ran into the want for this on username and password fields on the weekend so I decided to take a stab at it. The WhatWG bug also indicates there is demand for this and how it's better than just using @pattern. This seems to work but I'm having to fix the W3C web platform tests on this feature to work on Gecko. Shall I email an intent to implement email at this point or should I gather consensus from peers first? See also: * Spec addition: http://html5.org/tools/web-apps-tracker?from=8205&to=8206 * WhatWG bug: https://www.w3.org/Bugs/Public/show_bug.cgi?id=10053  https://github.com/w3c/web-platform-tests/issues/923
Feel free to email intent to implement. That's the best way to get feedback from peers.
Did you email the intent to implement? I can't it on dev-platform...
PS: 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
Matt, given that you haven't worked on this in a couple of years, I'm guessing that you wouldn't mind if I complete your patch? This feature is in the WhatWG spec, we already support maxLength, *and* Chrome supports both min and maxLength, so I doubt it would be controversial, but I'll definitely send an intent to implement and ship just in case (assuming you don't want to tackle this one yourself anytime soon).
Created attachment 8776240 [details] [diff] [review] 932755-add_support_for_input_and_textarea_minLength_and_tooShort.diff In the interest of getting this done, here's a rebased version of the work-in-progress patch that also accounts for the note in comment 5 (ie, trying to a set maxLength less than the current minLength throws, and vice-versa). This patch needs to be applied on top on the patch I'm writing in bug 613019. It should be ready for review once some mochitests are written for it. Sorry if I'm stepping on your toes, :MattN!
Created attachment 8780789 [details] [diff] [review] 932755-add_support_for_input_and_textarea_minLength_and_tooShort.diff It doesn't seem like :MattN has the time to deal with this right now, so I've gone ahead and finished the patch by adding minlength tests where maxlength tests are in the tree. This makes for a large file, but the non-test stuff is still the same as it was in the patch I'm obsoleting (if that helps speed up review). Some potentially useful notes about the test changes: - I updated the maxlength tests to account for the fact that user-interaction is now needed in the spec before the state can ever become invalid. This required moving the reftests into test_reftests_with_caret.html. - I also changed the "todo" :-moz-ui-valid/invalid reftests while I was at it (so they test the same way the :valid/invalid tests do). - There are some maxlength-related tests that don't analogously apply to minlength (because browsers currently don't let users type more text in a maxlength field than it can hold, yet don't restrict minlength fields the same way). A try run seems fine so far: https://treeherder.mozilla.org/#/jobs?repo=try&revision=12454725dbcb
Created attachment 8780848 [details] [diff] [review] 932755-add_support_for_input_and_textarea_minLength_and_tooShort.diff Turns out that I had missed marking a couple tests as passing, so here's a revised patch. Try otherwise seemed fine, just unrelated issues. Here's a fresh run with the new patch: https://treeherder.mozilla.org/#/jobs?repo=try&revision=1f6a5b2e5d7e
Created attachment 8781821 [details] [diff] [review] 932755-add_support_for_input_and_textarea_minLength_and_tooShort.diff Alright, let's try again. Here's a rebased patch. Carrying over r+.
patching file dom/tests/mochitest/ajax/jquery/test/unit/core.js Hunk #1 FAILED at 314 Hunk #2 FAILED at 388 Hunk #3 FAILED at 415 3 out of 3 hunks FAILED -- saving rejects to file dom/tests/mochitest/ajax/jquery/test/unit/core.js.rej This is on top of inbound in case that matters.
Created attachment 8781829 [details] [diff] [review] 932755-add_support_for_input_and_textarea_minLength_and_tooShort.diff Ah, sorry, I didn't remember to rebase against inbound. Here's a fresh patch rebased against inbound.
Pushed by firstname.lastname@example.org: https://hg.mozilla.org/integration/mozilla-inbound/rev/f4d0e045901e Add support for input/textarea minLength and tooShort. r=mrbkap