[whatwg] required attribute for checkbox/select
Ian Hickson
ian at hixie.ch
Mon Mar 21 03:21:59 PST 2005
On Sun, 20 Mar 2005, Matt Wright wrote:
> > >
> > > 2) Why can't the required attribute apply to a select field? It is
> > > common for application designers to want to force the user to
> > > manually select an option. They will do something like <option
> > > value="">Please select a valid option</option>. You could easily
> > > word the document to say that:
> >
> > That's, IMHO, semantic abuse. That isn't an option, and shouldn't
> > be called an option.
>
> It may be semantic abuse, but I think it is pretty common usage in
> actual web development practice.
Oh, sure, I don't deny that. So is "<font>", though, and we're not going
to encourage that either.
> It's technically not a valid option, but it's the best we've got in HTML
> if you don't want the browser to preselect an option in your select box.
But if we're going to fix the problem here, it would be better to fix the
problem by providing real menus or a real way to make <select>s have a
label and require a selection, than it would by kludging the current model
to do it without fixing the semantics.
I fully agree that we need to cater for the use case you gave; but I think
it would need non-trivial changes and therefore I would like us to wait
until the next version of the Web Forms draft.
> I simply think that my original proposal makes the most sense from a
> real-world web-apps implementation standpoint. Why deny authors the
> ability to require a select element when this method would match up with
> normal day-to-day usage of the element while not causing any negative
> side-effects (that I know of)?
As mpt pointed out, I do not really think the interaction model you are
proposing really makes sense for users who are used to list boxes.
> However, if you cannot get past the semantic conflict, wouldn't it at
> least make sense to allow the required attribute on the select tag and
> have it say that at least one option must be selected? For any single
> select it would always be satisfied (since one option is always selected
> by the browser), but for a multiple select at least one option would
> have to be selected (since one is not always selected by the browser by
> default)?
What's the use case for multiple select being required?
--
Ian Hickson U+1047E )\._.,--....,'``. fL
http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,.
Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
More information about the whatwg
mailing list