[whatwg] select element should have a required attribute

Garrett Smith dhtmlkitchen at gmail.com
Mon Aug 9 22:09:21 PDT 2010

On 8/9/10, Jonas Sicking <jonas at sicking.cc> wrote:
> On Mon, Aug 9, 2010 at 4:35 PM, Ian Hickson <ian at hixie.ch> 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.

<select id="p">
  <option selected disabled>

Is not interoperable. In some browsers (IE7 an below, Webkit)
submitting the form results in the SELECT being submitted with
disabled option having the value, while in other browsers (Gecko),
SELECT is not successful.

This was discussed here before.

>> On Thu, 22 Jul 2010, Mounir Lamouri wrote:
>>> 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.
>> That seems like an invalid use of <option> to me. It would be better as:
>>   <label> Choose an option: <select> ... </select> </label>
> Many times you want the user to make an explicit choice, rather than
> just leaving whatever was already selected. What many websites do is:
> <label>Choose an option:
>   <select>
>     <option></option>
>     <option>value 1</option>
>     <option>value 2</option>
>     <option>value 3</option>
>   </select>
> </label>

The first option should be selected, resulting in the select having
value="". If `required` is specified, and the user selects an empty
option (the first option in the list) and submits the form, what do
you think should happen?

> Or
> <select>
>   <option value="">Choose an option:</option>
>   <option>value 1</option>
>   <option>value 2</option>
>   <option>value 3</option>
> </select>

What should happen if the SELECT has `required`?

> It would be good if it was possible to use @required together with
> these usage patterns. I don't believe that any other feature of HTML
> supplies the same, or similar, functionality? While authors could do

> While I guess we could wait for v2 for this feature, it seems like a
> glaring omission and inconsistency in the way that @required works.

I've seen sites that require the user to pick a SELECT value, sure. I
was just using Bing.com search feedback which requires that.

Bing.com search feedback form is not the best example of the need for
this feature, though because it throws multiple javascript errors and
fails to submit in Firefox 3.6.

I know I've seen other sites using this before but can't think of them
right now.


More information about the whatwg mailing list