[whatwg] select element should have a required attribute
Garrett Smith
dhtmlkitchen at gmail.com
Fri Jun 18 13:19:57 PDT 2010
On 6/18/10, Ashley Sheridan <ash at ashleysheridan.co.uk> wrote:
> On Fri, 2010-06-18 at 11:35 +0200, Mounir Lamouri wrote:
>
>> Hi,
>>
>> I'm wondering why select element do not have a required attribute. It
>> seems to be perfectly suitable. With the required attribute, select
>> element would be able to suffer from being missing and the :required
>> pseudo-class could apply.
>>
>> Is there a reason why the select element has no required attribute or
>> it's only an omission?
>>
>> Related bug:
>> http://www.w3.org/Bugs/Public/show_bug.cgi?id=9625
>>
>> Thanks,
>> --
>> Mounir
>
>
> Required as in it should always have a value sent? If so, then it always
> does. The default value for a select element is not an empty string as
> an <option> is always there (unless someone has been stupid enough to
> create an empty select list.)
>
> As such, some sort of value will always be sent.
>
There are two cases where that is not true.
1) The SELECT has no name
2) The selected option is disabled, as:
<select name="striped-pet">
<option disabled selected>choose one (required)</option>
<option>Lemur</option>
<option>Okapi</option>
</select>
The selected option being disabled is in common use. This option
should generate no value, but it could be required by the
application).
Implementations vary on actual behavior. See also:
https://bug-20184-attachments.webkit.org/attachment.cgi?done=true&id=22519
More information about the whatwg
mailing list