W3C home > Mailing lists > Public > whatwg@whatwg.org > August 2010

[whatwg] select element should have a required attribute

From: Mounir Lamouri <mounir.lamouri@gmail.com>
Date: Tue, 10 Aug 2010 02:13:32 +0200
Message-ID: <4C6099AC.40902@gmail.com>
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

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:26 UTC