- From: Sander <html5@zoid.nl>
- Date: Thu, 07 Jun 2007 21:21:44 +0200
Michel Fortin schreef: > Le 2007-06-06 ? 6:56, Sander a ?crit : > >> I'd like to see a minlength attribute that can be used on the same >> elements as the maxlength attribute. > > I'm not sure a minlength attribute like this can be consistent with > maxlength. > > The maxlength attribute prevents users from entering more characters > than the attribute's value. Should a minlength attribute prevent you > from erasing characters when it would cause the value to be less > characters than specified? That would be strange, if not completely > useless. Hadn't thought of it that way, but more like a validation attribute. > Also, the maxlength attribute also cause the truncation of any value > set on the input. For instance, if your markup contains this: > > <input maxlength="3" value="12345"> > > ... it'll result in the value being truncated to "123". Before HTML5 there was no HTML validation (as opposed to JS validation) for form controls. So truncating the input value was probably the only way to force the given maxlength (perhaps that's also why there wasn't a minlength attribute before). As HTML5 will get validation attributes like pattern= anyway, maybe it would be consistent to have maxlength act in the same manner. I guess it won't really break things as the end result will be the same, but maybe I'm wrong. > Should an input with minlength smaller than it's value be filled with > padding characters? Before or after the value? And what happens to > those characters as you type? That's not what I had in mind. If the value of the form control is shorter than the value of the minlength attribute, form submission must be blocked. > If that's not what you want (and I'm pretty sure it's not) I don't > think such an attribute, if added, should be called minlength. Perhaps > requiredlength or something like that would fit better. I wouldn't mind giving it another name, like requiredlength. Although minlength is shorter and makes a better pair with maxlength ;-) But in the end it's about its function: providing authors a regExp-less way to set a minimum/required length. cheers, Sander
Received on Thursday, 7 June 2007 12:21:44 UTC