devxlogo

Selecting Three Radio Buttons

Selecting Three Radio Buttons

Question:
I want to validate a form so that three radio buttons may be checked, but no more. This will be used in a “what are your top three choices” type of situation

Answer:
Radio buttons are, by definition, a type of button where only one of a group can be checked. So, there’s no way to do what you want with radio buttons.

However, you can fake this by either (a) setting all of your radio buttons to be in unique groups, so that changing one won’t reset the others, or (b) using checkboxes instead. Either way, you’d then want to have an onSubmit handler that verifies that just three have been chosen.

devx-admin

Share the Post: