Agree on the "required" attribute utility also for the "select" element. Actually I thought it was already so, seems not !
Was there a reason to add the "required" attribute to other controls and not to "select" ? +1 Diego On Thu, Jul 22, 2010 at 4:19 PM, Mounir Lamouri <mounir.lamo...@gmail.com>wrote: > On 06/18/2010 01:04 PM, Ashley Sheridan 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. > > I'm getting back to this subject because the answers I got were not > really convincing. Nor the answers from the previous thread [1]. > > I see three reasons to have @required for <select>: > > 1. A typical use case of <select> is to have <option value=''>Choose an > option</option> as a default value. Having @required would prevent > authors to write any js check when they are using <select> like that. > 2. For <select multiple>, it is possible to not select any option. The > required attribute can be really helpful here too. > 3. Having @required for <select> will be consistent and semantically > better. As I see it, with HTML5 Forms, I should be able to do > :not(:required) { display: none; } and still be able to submit the form > (I should not hide submit controls actually ;)). So, even for the simple > <select>'s with a non-null default, knowing it is required would be good > for everyone. > > Feedbacks are welcome :) > > [1] > > http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2006-October/007331.html > > Thanks, > -- > Mounir >