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

[whatwg] select element should have a required attribute

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Tue, 10 Aug 2010 11:25:55 -0700
Message-ID: <AANLkTi=n3K72h+7RAb2Xp+G+oYavrgPdGe1Ww2ugJPhj@mail.gmail.com>
On Tue, Aug 10, 2010 at 11:12 AM, Mike Wilcox <mike at mikewilcox.net> wrote:
> This seems like the ideal situation to use a placeholder attribute:
> <select required="true" placeholder="Select an item...">
> ? ?<option value="Foo"> Foo </option>
> ? ?<option value="Bar"> Bar </option>
> ? ?<option value=""> None </option>
> </select>

Almost, but not quite.

Yes, the value used in this situation is essentially a placeholder
value - it performs the same function as <input placeholder>.
However, an <input type=text placeholder=foo required> will fail
validation if the user doesn't interact with it, while a similar
<select> will not at the moment (it will just submit the first value).

It could be possible to define the interaction of <select>,
@placeholder, and @required in such a way that it works intelligently,
so that the <select> with a placeholder fails validation if the user
doesn't interact with it, but that may be too much magic.

I think I'd prefer the simple solution of having it fail @required
validation in the same way that text inputs do - when their value is
the empty string.

Received on Tuesday, 10 August 2010 11:25:55 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:59 UTC