[whatwg] select element should have a required attribute
mikko.rantalainen at peda.net
Thu Aug 12 01:31:22 PDT 2010
2010-08-11 12:31 EEST: Jonas Sicking:
> On Wed, Aug 11, 2010 at 2:03 AM, Mikko Rantalainen
> <mikko.rantalainen at peda.net> wrote:
>> Stuff I don't want to see (combined with @required):
>> - first option is always special
>> - empty string as the value is special
>> - option without a value is special
> Do you consider it a problem for <input type=text required> to treat
> empty string special?
> If yes, do you think @required should be removed completely?
> If no, why do you consider it a problem for <select>?
Now that you ask, I don't like <input type=text required> to treat empty
string special either. I'd rather have the author specify the value that
will be not accepted (I consider @required in the current spec to mean
"empty string will not be accepted"). As such, I would rather have
author specify <input type=text disallow=""> to disallow empty string.
A possible use case where this feature could be useful already (and
cannot be fulfilled with @required):
1) An user is trying to register a new user account on some system
and uses "foo" as the nick name.
2) The registration form is otherwise successful, but the system
returns with an error message saying that nick "foo" was already
taken. In such case, the actual input field could be specified as:
<input type=text value="foo" disallow="foo">
That is, the field will be prefilled with "foo" but the field also
contains extra information that the value "foo" will not be
accepted in any case. The prefilled "foo" may have some value for
the use and as a result, it does make more sense to prefil with
"foo" instead of presenting an empty field with @required.
The same behavior can already be implemented with @pattern but I
believe that @disallow would be easier to understand to most authors. If
@disallow were introduced, the @required should be removed completely
because it doesn't provide any functionality not provided by @disallow.
However, if @required is kept as is for input type="text", the I guess
it would make sense to accept @required for <select> and make the empty
string special for that, too. I don't like this option, but some user
agents already support @required, which does have some weight, too.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 198 bytes
Desc: OpenPGP digital signature
More information about the whatwg