Agree on the "required" attribute utility also for the "select" element. Actually I thought it was already so, seems not !<br><br>Was there a reason to add the "required" attribute to other controls and not to "select" ?<br>
<br>+1<br><br>Diego<br><br><br><div class="gmail_quote">On Thu, Jul 22, 2010 at 4:19 PM, Mounir Lamouri <span dir="ltr"><<a href="mailto:mounir.lamouri@gmail.com">mounir.lamouri@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
On 06/18/2010 01:04 PM, Ashley Sheridan wrote:<br>
> On Fri, 2010-06-18 at 11:35 +0200, Mounir Lamouri wrote:<br>
>> Hi,<br>
>><br>
>> I'm wondering why select element do not have a required attribute. It<br>
>> seems to be perfectly suitable. With the required attribute, select<br>
>> element would be able to suffer from being missing and the :required<br>
>> pseudo-class could apply.<br>
>><br>
>> Is there a reason why the select element has no required attribute or<br>
>> it's only an omission?<br>
>><br>
>> Related bug:<br>
>> <a href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=9625" target="_blank">http://www.w3.org/Bugs/Public/show_bug.cgi?id=9625</a><br>
>><br>
>> Thanks,<br>
>> --<br>
>> Mounir<br>
><br>
> Required as in it should always have a value sent? If so, then it always<br>
> does. The default value for a select element is not an empty string as<br>
> an <option> is always there (unless someone has been stupid enough to<br>
> create an empty select list.)<br>
><br>
> As such, some sort of value will always be sent.<br>
<br>
I'm getting back to this subject because the answers I got were not<br>
really convincing. Nor the answers from the previous thread [1].<br>
<br>
I see three reasons to have @required for <select>:<br>
<br>
1. A typical use case of <select> is to have <option value=''>Choose an<br>
option</option> as a default value. Having @required would prevent<br>
authors to write any js check when they are using <select> like that.<br>
2. For <select multiple>, it is possible to not select any option. The<br>
required attribute can be really helpful here too.<br>
3. Having @required for <select> will be consistent and semantically<br>
better. As I see it, with HTML5 Forms, I should be able to do<br>
:not(:required) { display: none; } and still be able to submit the form<br>
(I should not hide submit controls actually ;)). So, even for the simple<br>
<select>'s with a non-null default, knowing it is required would be good<br>
for everyone.<br>
<br>
Feedbacks are welcome :)<br>
<br>
[1]<br>
<a href="http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2006-October/007331.html" target="_blank">http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2006-October/007331.html</a><br>
<br>
Thanks,<br>
--<br>
<font color="#888888">Mounir<br>
</font></blockquote></div><br>