Is there standard client behavior for sending empty multiple selections?

http://www.w3.org/TR/html401/interact/forms.html#edef-SELECT

It does not indicate how the client should behave if the empty selected plural number is empty. Does anyone know if there is a standard for this?

+3
source share
2 answers

Unfortunately, I don’t have time to check this out, but I hope the following helps you ...

If I am not mistaken, the first element is selected by default when the page loads. Therefore, create a very simple HTML file with form and select with the active attribute multiple and several options . Then open the file to see what happens in several browsers such as Chrome, Firefox, Internet Explorer, Opera, and Safari.

Another thing is to see what HTML5 says about this: http://dev.w3.org/html5/spec/Overview.html#the-select-element .

UPDATE

The W3C HTML 4.01 standard states this (scroll a bit down the link above):

17.6.1 Preselected Parameters

You can select zero or more pre-selected for the user. User agents should determine which ones are preselected as follows:

If the OPTION element is not selected, the set of attributes, the behavior of the user agent for selecting the option is selected undefined. The note. since the existing implementations of the case are different, the current specification is different from RFC 1866 ([RFC1866], section 8.1.3), which states: the initial state has the first option, if only the SELECTED attribute is present on any elements. Because user agent behavior is different, authors should ensure that each menu includes a pre-selected option by default.

If one OPTION element has a selected attribute, it must be preselected. If a SELECT element has many attributes and more than one OPTION element has a selected set of attributes, they should all be preselected. An error is considered if several OPTIONS an element has a selected set of attributes and a SELECT element does not have a set of many attributes. user agents may vary depending on how they handle this error, but you should not pre-select more than one choice.

+2
source

Unfortunately, @Alerty is wrong. If the multiple attribute is present in the select element, but none of the option elements has the selected attribute, then by default no element is selected. (Tested on IE 9, FF 5, Chrome 13, and Safari 5 on Win 7.)

So what should a web browser do if the user does not select anything but submit the form? He should do exactly what you expect: do not submit choices. And this is exactly what the current version of the HTML5 specification says:

"The multiple attribute is a logical attribute. If an attribute is present, then the select element represents a control for selecting zero or more parameters from the parameter list."

http://dev.w3.org/html5/spec/Overview.html#the-select-element

+1
source

Source: https://habr.com/ru/post/1342776/


All Articles