W3C home > Mailing lists > Public > whatwg@whatwg.org > June 2007

[whatwg] Web Forms attributes: minlength / autocomplete

From: Sander <html5@zoid.nl>
Date: Wed, 06 Jun 2007 17:15:16 +0200
Message-ID: <4666CF84.6030106@zoid.nl>

Thomas Broyer schreef:
> 2007/6/6, Sander:
>> But if you can use pattern to define a minimal length, than I'm sure you
>> can define a minimal length bigger than 0, which makes it required.
>
> No, because "Controls with no value selected do not need to match
> their pattern. (Although if they are required controls, they will stop
> submission for that reason anyway.)"
>    ? http://www.whatwg.org/specs/web-forms/current-work/#the-pattern
>
> In other words: you can leave it empty, but if you don't, you must
> follow this pattern.

I guess I missed that part. Thanks.


>> Using a 'required' attribute is much easier of course, but so would be
>> minlength.
>
> Yes, minlength could be handy, but pattern=".{3,}" is not that
> difficult (equivalent to minlength=3 here).

I see it's not really difficult, that's true (as I said before, I don't 
know much about regular expressions). But as I more than once heard the 
arguments that we must avoid as much possibilities for authors to get it 
wrong and that HTML authoring must be not for professionals only (as in 
the discussion why HTML parsers should not be as rigid as XML parsers), 
I wonder if pattern=".{3,}" passes those arguments. Even though there 
are only 5 characters... if it has no meaning to someone they can easily 
make mistakes: "{3,}." or ",{3.}". Easy as it is, this stuff is 
abrcadabra to a lot of authors.


>> As for the input type url and email... you're right But why is it
>> necessary that user agent recognize these as such? If it's because they
>> have to be able to validate the values of these fields then pattern
>> would be sufficient as well. The semantics would not be the same of
>> course and that's why I added "(in a technical manner)".
>
> UAs are expected to let you choose a VCard in your address books or an
> URL from either a VCard or your browser's history or bookmarks.
>
> See also the VCARD_NAME attribute:
> <http://msdn2.microsoft.com/en-us/library/ms535130.aspx>
>
> ...but emails and URLs are what people really use actually (when
> giving information about someone else).

Yes, semantics are quite different when using type= than with only pattern=


> maxlength was already in HTML4, so (i guess) it's kept merely for
> backwards compatibility, but is actually equivalent to a
> pattern=".{,N}" where N is the maxlength value.
> minlength doesn't exist, and given that you can achieve the same
> effect using a pattern (see above), there's no real reason to
> introduce yet another attribute.

Easy as these 2 formats may be, and given the fact that we keep 
maxlength, why not add minlength? It's more logical, combined with 
maxlength and it's a lot easier to use, with less possibilities to make 
mistakes.
So, the real reason would be to make life easier for auhors, most of who 
don't know anything about regular expressions.


>> For instance some reference codes, zip codes or telephone numbers have a
>> certain length, but maybe not alway the same notation.
>> As you know telephone numbers in the Netherlands have 10 digits, but
>> some people prefer to write them all together, and others seperate them,
>> using spacers and/or hyphens. If you want to allow people to write their
>> number in their own fashion (which is a good thing from a usability
>> point of view) then you know the number must be at least 10 characters
>> long. Same for Dutch zip codes that are sometimes written with a space
>> in them and sometimes not, but they're at least 6 characters long.
>
> Actually, for phone numbers, i think you should really use a pattern...
> e.g. pattern="[\s()-.]*([0-9][\s()-.]*){10}"
> (allows for any number of spaces, parens, dots or hyphens, followed by
> exactly 10 digits, which eventually are seperated by any number of
> spaces, parens, dots or hyphens; then on the server side, you just
> remove ever space, paren, dot and hyphen and you're given a 10-digit
> phone number)

For all kinds of applications that would indeed be a better solution, 
but for a lot of sites and authors that's not necessary and that pattern 
is just way too complicated.


>> Perhaps you want users to come up with a password that's at least 6
>> characters long or maybe you just want your replicants to come with a
>> better argument than "just because", so you could set minlength="13" ;-)
>> I'm sure there are hundreds of uses for a minlength attribute, and
>> pattern is just harder to use because of the regular expressions. I'd
>> even say it's too hard to use for a lot of people.
>
> For the use cases you're giving, you probably want some server-side
> code to do some additional checks (is the password containing at least
> one letter and one number? does it contain some illegal characters?).
> These checks could be done on the client-side with no coding, just
> using pattern=.

I guess I forget to mention I'm not at all against the pattern attribute 
either. I think it adds great possibilities. It's just that its values 
can not be read or written by most authors.


> For the minlength= use case, maybe a "note to authors" in the spec
> giving pattern=".{N,}" or pattern="[\s\S]{N,}" as a replacement would
> be enough ("replace N with the minimum length of the field value")

<note-to-authors required="required">
;-)


cheers,
Sander
Received on Wednesday, 6 June 2007 08:15:16 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:58:56 UTC