These forums are currently read-only due to receiving more spam than actual discussion. Sorry.

It is currently Sat Dec 02, 2017 4:06 pm Advanced search

WebForms 2: validation of required select field

Do you think the HTML spec should do something differently? You can discuss spec feedback here, but you should send it to the WHATWG mailing list or file a bug in the W3C bugzilla for it to be considered.

WebForms 2: validation of required select field

Postby FataL » Thu May 01, 2008 9:36 pm

Is it just wrong implementation in Opera and Weston Ruters' JavaScript that empty select value ignores by validator? If so, I think that it should be clarified in specs.

See test page and further explanation here.

Update: I see now that there is no required attribute for select in specs.
Probably this should be corrected to allow required attribute for SELECT. In most cases SELECTs have first option blank or "please select" with no or empty value, so SELECT needs validation.

Also consider to make invalid (if field is required) check boxes and radio buttons with empty value. It may be helpfull in some cases.
FataL
<h6>
 
Posts: 9
Joined: Thu Jun 28, 2007 7:02 pm

Postby zcorpan » Mon May 05, 2008 6:12 pm

zcorpan
<article>
 
Posts: 807
Joined: Tue Feb 06, 2007 8:29 pm
Location: Sweden

Postby FataL » Tue Nov 10, 2009 7:30 pm

Despite some opinions personally I still think that REQUIRED attribute perfectly applies to SELECT and will not conflict with anything that worked previously. At least not much than REQUIRED attribute on INPUT elements.

This is very common case when first option of select is empty one, and user need to select something else from the list to comply. If there is a need to submit empty value, REQUIRED attribute should not be used. Simply as that!

P.S. Here is [url=http://my.opera.com/community/forums/topic.dml?id=285530]another person asking the same question[/url[.
FataL
<h6>
 
Posts: 9
Joined: Thu Jun 28, 2007 7:02 pm

Postby zcorpan » Tue Nov 10, 2009 11:32 pm

I agree with you (I sent the original email suggesting this back in 2006). This is noted in the spec source as a "v2" feature that might be added to the spec in the future:
<!-- Proposals for v2:
* <select value=""> as an alternative to <option selected>
http://developers.slashdot.org/comments ... d=22142072
<Philip`> http://www.ipiao.com.cn/ does <select size="1" name="to"><script>City_Default="PEK"</script><SCRIPT language=javascript
src="/js/flightcity.js"></SCRIPT></select> which is the kind of thing that could be much simpler with <select value="PEK">
* a way to make the <select> not have a default value at all (ack
or to have a "placeholer" like value that doesn't count as a value being selected but shows a prompt until a value is selected
* once we can have no default, a way to require="" a value.
ack Weston Ruter: http://weston.ruter.net/projects/test-c ... t-element/
q.v. http://lists.whatwg.org/pipermail/whatw ... 17583.html
-->


It's relatively easy to work around the lack of this feature with some script, though.

If you want this soonish, I'd suggest you send an email to whatwg or file a bug in W3C bugzilla summarizing use cases for this feature, and maybe try to convince browser vendors to add this feature (e.g. by filing bugs).
zcorpan
<article>
 
Posts: 807
Joined: Tue Feb 06, 2007 8:29 pm
Location: Sweden


Return to Feedback on the Specs

Who is online

Users browsing this forum: No registered users and 1 guest