[whatwg] select element should have a required attribute

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.

~TJ

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