W3C home > Mailing lists > Public > public-html@w3.org > April 2008

Re: required radio buttons and checkboxes

From: Ben Boyle <benjamins.boyle@gmail.com>
Date: Wed, 23 Apr 2008 21:25:54 +1000
Message-ID: <5f37426b0804230425k7e96ac08w8bb114efe4800cea@mail.gmail.com>
To: "Philip Taylor" <pjt47@cam.ac.uk>
Cc: "HTML WG" <public-html@w3.org>

Very twisted.

Thanks Phil.

On Tue, Apr 22, 2008 at 9:59 PM, Philip Taylor <pjt47@cam.ac.uk> wrote:
> > 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.

This explains the 'checked' status needed to satisfy a 'required'
input. I understand the behaviour. What isn't explained is whether
that 'required' status is determined by one or more required
attributes within the group.


>  It has an effect on exactly where validity-related events go - if you mix
> required and not-required radio buttons in a single group, 'invalid' events
> will only be sent to those with a 'required' attribute; and the ':invalid'
> pseudo-class will only apply to elements with 'required'.

Which is interesting ...

> > When a radio group has no checked radio button and more than one of the
> > radio buttons is marked as required, the UA, when alerting the user,
> > should only tell the user that the radio group as a whole is missing a
> > value, not complain about each radio button in turn, even though all of
> > the radio buttons marked with the required attribute would have the
> > valueMissing flag set.

'more than one of the radio buttons is marked as required' suggested
@required must be applied to at least two input elements with the same
name (and type=radio of course), i.e. in the group. Which would make
it impossible to 'require' a single radio button (though it's not a
good idea to have a single radio button anyway - I'm just talking it
through for my own clarification).

It may be possible in a group of checkboxes to 'require' individual
boxes be selected? Sometimes this is useful business logic (e.g. you
have a set of options, and a previous action has caused some to be
checked - and required - from that point).

Must admit I'm finding it harder to comprehend than xforms
select1/select controls and required expressions (and they're a good
bit richer in functionality). Will get there though.

cheers
Ben
Received on Wednesday, 23 April 2008 11:26:29 UTC

This archive was generated by hypermail 2.3.1 : Monday, 29 September 2014 09:38:54 UTC