Example 21: "required" attribute on checkboxes & radio buttons
The specification states:
For checkboxes, the
required
attribute shall only be satisfied when one or more of the checkboxes with that name in that form are checked.For radio buttons, the
required
attribute shall only be satisfied when exactly one of the radio buttons in that radio group is checked.
Specifying a required
attribute on a checkbox
only makes sense when there are multiple checkbox
es defined to be in a group by providing each with the same name
attribute (as the quote from the specification makes reference to). In Opera 9.23 when a required
attribute is specified on either one or all radio
buttons in a group, the form validates if one of the buttons is checked. With regard to a group of checkbox
es, however, when the required
attribute is defined on one checkbox
, that one specific checkbox
must be checked in order for the form to validate in Opera. If the required
attribute is defined on all checkbox
es in the group, then the form only validates if every checkbox
is checked. Opera's implementation, then, is faulty, since it does not make sense to present the user with a single checkbox that must always be checked, and since the specification states that UAs must apply the required
attribute onto the entire group of checkboxes, not every single one individually.