[whatwg] select element should have a required attribute

On Tue, 2010-08-10 at 11:35 +0200, Mounir Lamouri wrote:

> On 08/10/2010 07:09 AM, Garrett Smith wrote:
> >> 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?
> 
> Like for <input> or <textarea>, if select.value is the empty string, the
> select element suffers for being missing.
> 
> >> 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`?
> 
> ditto
> 
> --
> Mounir


If you receive an empty text box then a required element works to
validate against empty input. As you produce the input for the select
list, it's pretty stupid to say that it shouldn't have an empty string
for a value because you put it there.

I can think of lots of places where an empty string is in-fact very
useful for a select element, such as filters on search results forms,
but if there's any places that I want a value, then I don't leave empty
elements lying around. If you need to do that, then maybe use radio
buttons instead.

Thanks,
Ash
http://www.ashleysheridan.co.uk


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20100810/76e228a6/attachment-0001.htm>

Received on Tuesday, 10 August 2010 02:35:53 UTC