[whatwg] Web Forms attributes: minlength / autocomplete

Sander html5 at zoid.nl
Thu Jun 7 12:21:44 PDT 2007


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





More information about the whatwg mailing list