I've created a couple of fieldsets with mandatory radio select lists in them, the 1st with 3 choices, the 2nd w/ 2, e.g.:

  • 0=>Tons
  • 1=>Cubic Feet
  • 2=>Linear Feet

and

  • 0=>No
  • 1=>Yes

I left the default value field blank when creating these, but the 0 index option is checked, nevertheless, causing the form to pass validation even though the user hasn't chosen an option. Is this a bug?

Comments

Anonymous’s picture

Update — sorry, I meant to say I didn't check any of the radio inputs when creating the form (there is no 'default value' field in this particular dialog).

robertom’s picture

I left the default value field blank when creating these, but the 0 index option is checked, nevertheless, causing the form to pass validation even though the user hasn't chosen an option. Is this a bug?

if I've understood what you mean I don't think that this is a bug, this is a normal behavior of radio button

I quote part of http://www.w3.org/TR/html401/interact/forms.html#radio

Radio buttons are like checkboxes except that when several share the same control name, they are mutually exclusive: when one is switched "on", all others with the same name are switched "off". The INPUT element is used to create a radio button control.
If no radio button in a set sharing the same control name is initially "on", user agent behavior for choosing which control is initially "on" is undefined. Note. Since existing implementations handle this case differently, the current specification differs from RFC 1866 ([RFC1866] section 8.1.2.4), which states:

At all times, exactly one of the radio buttons in a set is checked. If none of the elements of a set of radio buttons specifies `CHECKED', then the user agent must check the first radio button of the set initially.

Since user agent behavior differs, authors should ensure that in each set of radio buttons that one is initially "on".

Anonymous’s picture

You're right, of course. I'll have to include a default "Choose One" button & use JavaScript & some custom PHP to ensure that the user checks one of the non-default buttons.

Anonymous’s picture

OK, I'm not sure if it's because I applied this patch,, or because I got added custom index => key values (changed index 0 to a human-friendly key), but now I can create radio groups w/o a default checked button.

Anonymous’s picture

Status: Active » Closed (fixed)