5

I'm creating a form that contains multiple checkboxes. The problem that I am facing is: When I use the property "required" in the checkboxes, if the user check just one of them, all of the others will alert " You must select this checkbox".

Is there anyway, that I can make this property "required" check if the user has checked at least one of the checkboxes?

Regards,

Otacon.

Otacon
  • 332
  • 2
  • 4
  • 9

1 Answers1

0

If you want to require the user to select at least one (but maybe more than one) of a group of checkboxes, you will have to use javascript to enforce that. You can't accomplish that with the required property.

If you want to require exactly one item to be selected, then you can use a radio group with no initial selection and set that to required. But, that doesn't work quite the same way as checkboxes in that you can't select more than one.

A little less intuitive to the user is to use a multiselect list where the user can select one or more items. I haven't tried "required" on that, but presumably any selection in the list (one or more) would meet the "required" criteria.

jfriend00
  • 683,504
  • 96
  • 985
  • 979