Is There A Standard Client Behaviour For Submitting An Empty Select Multiple?
Solution 1:
Sadly, I do not have the time to test this, but I hope the following can help you...
If I am not mistaken, the first element is selected by default when the page is loaded. Therefore, create a very simple HTML file with a form
and a select
that has the multiple
attribute active and with a few options
. Then, open the file to see what happens in a few browsers such as Chrome, Firefox, Internet Explorer, Opera and Safari.
Another thing would be to look what HTML5 says about this here: http://dev.w3.org/html5/spec/Overview.html#the-select-element.
UPDATE
The W3C HTML 4.01 standard states this (scroll a bit down in the link you provided):
17.6.1 Pre-selected options
Zero or more choices may be pre-selected for the user. User agents should determine which choices are pre-selected as follows:
If no OPTION element has the selected attribute set, user agent behavior for choosing which option is initially selected is undefined. Note. Since existing implementations handle this case differently, the current specification differs from RFC 1866 ([RFC1866] section 8.1.3), which states: The initial state has the first option selected, unless a SELECTED attribute is present on any of the elements. Since user agent behavior differs, authors should ensure that each menu includes a default pre-selected OPTION.
If one OPTION element has the selected attribute set, it should be pre-selected. If the SELECT element has the multiple attribute set and more than one OPTION element has the selected attribute set, they should all be pre-selected. It is considered an error if more than one OPTION element has the selected attribute set and the SELECT element does not have the multiple attribute set. User agents may vary in how they handle this error, but should not pre-select more than one choice.
Solution 2:
Unfortunately, @Alerty is mistaken. If the multiple attribute is present on the select element but none of the option elements have the selected attribute, then no element is selected by default. (Tested on IE 9, FF 5, Chrome 13, and Safari 5 on Win 7.)
So, what should the web browser do if the user doesn't select anything yet submits the form? It should do exactly what you would expect: Submit no selection. And that's exactly what the current version of the HTML5 spec says:
"The multiple attribute is a boolean attribute. If the attribute is present, then the select element represents a control for selecting zero or more options from the list of options."
http://dev.w3.org/html5/spec/Overview.html#the-select-element
Post a Comment for "Is There A Standard Client Behaviour For Submitting An Empty Select Multiple?"