[whatwg] [WF2] <select required>

On Oct 23, 2008, at 5:31 AM, Ian Hickson wrote:

> This use case is definitely something we want to consider, but I don't
> think it's about required="". It's about an option in the <select>  
> being a
> non-option (as it were). <select> by definition can't have nothing
> selected. That's what it means.
>
> The issue about a placeholder value is listed as an open issue in the
> spec, and will probably be addressed at some future point.

This is an interesting point I hadn't considered.  It's *very* common  
to use the first <option> in a <select> as a non-choice such as  
"Choose one...", setting the value to something unique (often "" but  
it could be something else if "" is a valid choice) so it can be  
treated as a non-selection.  This serves *precisely* the same purpose  
as the placeholder attribute on text input fields, which I had  
assumed wouldn't be valid for <select>.

I suggest that the placeholder attribute should indeed apply to  
<select>, and the behavior should be similar to the current practice  
of using the first <option>.  In particular, the placeholder should  
appear both on the collapsed menu, and at the top of the open menu,  
although it should not be selectable.

But the question is, when the menu is collapsed, when should the  
placeholder be displayed instead of one of the options?  Any time the  
value is ""?  Only until the user selects something?  Somebody  
smarter than me, please figure this out. :-)

-- 
Andy Lyttle
whatwg at phroggy.com

Received on Thursday, 23 October 2008 10:45:34 UTC