Example 21: "required" attribute on checkboxes & radio buttons
The specification states:
For checkboxes, the
requiredattribute shall only be satisfied when one or more of the checkboxes with that name in that form are checked.
For radio buttons, the
requiredattribute shall only be satisfied when exactly one of the radio buttons in that radio group is checked.
required attribute on a
checkbox only makes sense when there are multiple
checkboxes 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
checkboxes, 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
checkboxes 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.