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

[whatwg] select element should have a required attribute

From: Gordon P. Hemsley <gphemsley@gmail.com>
Date: Fri, 18 Jun 2010 12:58:29 -0400
Message-ID: <AANLkTimeLFij3Z0WzyG51dvrhUy8_-vKc9IZ4mL3mAVe@mail.gmail.com>
I'm not sure how you interpreted, but I wanted to clarify, in case it wasn't
clear.

I'm pretty sure this person is asking why @required isn't allowed on
<select> elements.

As in:
http://dev.w3.org/html5/markup/forms-attributes.html#shared-form.attrs.required

I don't know what the exact reasoning is for it not being on there, nor do I
know exactly how @required is supposed to be enforced, but I do think that
the method suggested in the bug is a bad one. Sometimes, authors will
include an empty <option> on purpose in order to allow for an empty option
to be selected.

Thus, as you've said, Ash, there will always be some sort of value sent from
a <select> element. And, including the option of an empty string, I can't
think of any way that there wouldn't be a value sent.

Gordon

On Fri, Jun 18, 2010 at 7:04 AM, Ashley Sheridan
<ash at ashleysheridan.co.uk>wrote:

>  On Fri, 2010-06-18 at 11:35 +0200, Mounir Lamouri wrote:
>
> Hi,
>
> I'm wondering why select element do not have a required attribute. It
> seems to be perfectly suitable. With the required attribute, select
> element would be able to suffer from being missing and the :required
> pseudo-class could apply.
>
> Is there a reason why the select element has no required attribute or
> it's only an omission?
>
> Related bug:http://www.w3.org/Bugs/Public/show_bug.cgi?id=9625
>
> Thanks,
> --
> Mounir
>
>
> Required as in it should always have a value sent? If so, then it always
> does. The default value for a select element is not an empty string as an
> <option> is always there (unless someone has been stupid enough to create an
> empty select list.)
>
> As such, some sort of value will always be sent.
>
>   Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>


-- 
Gordon P. Hemsley
me at gphemsley.org
http://gphemsley.org/ ? http://gphemsley.org/blog/
http://sasha.sourceforge.net/ ? http://www.yoursasha.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20100618/cdcbb392/attachment.htm>
Received on Friday, 18 June 2010 09:58:29 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:24 UTC