Required Validation on Radio Button Group

R

ryanmhuc

How would you do a required validation on a radio button group? I do
not want to use a RadioButtonList control and the CustomValidator
control only fires if their is a value in the ControlToValidator
control.
 
N

Nathan Sokalski

Because RadioButtons are in groups and there is always one selected (unless
there is not a default selected one when the page loads), most people do not
normally do validation on RadioButtons. If your situation is that you want
to make sure the user selects a RadioButton when none are selected by
default, you have several options:

1. Use the CustomValidator. Place the ID of any one of the RadioButtons in
the ControlToValidate property, you are still allowed to look at the other
RadioButtons when implementing the EvaluateIsValid method.

2. Write a custom control by inheriting from the BaseValidator class (this
is not hard to do)

3. Set the Checked property of any one of the RadioButtons to true so that
you do not need to worry about the validation

Hopefully this helps!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top