[whatwg] select element should have a required attribute

On 08/10/2010 01:35 AM, Ian Hickson wrote:
> On Fri, 18 Jun 2010, Mounir Lamouri wrote:
>>
>> I'm wondering why select element do not have a required attribute.
> 
> It's impossible to submit a <select> element (without a size="" attribute 
> or multiple="" attribute) without it having a value -- essentially, 
> required="" is already implied.

If you ignore that a lot of <select> (with no size and no multiple) have
their first option with only a label and no value to force the user to
intentionally choose an option.

>> 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.
> 
> This will still work without required="". :-)

Indeed, HTMl5 Forms form validation system will not block the form
submission but a lot of <select> in forms are actually required and, in
that case js checks will very likely block the form submission. That may
be a bad experience for the user (UA validation system and website
validation system may be inconsistent) and that is definitely a bad
experience for the authors who can't fully use the required attribute
and will have to keep their js checks only for required <select>'s (see
Jon Barnett's email).

--
Mounir

Received on Monday, 9 August 2010 17:13:32 UTC