Solved

Validating multiple radio buttons with custom validator control

Posted on 2012-04-02
2
474 Views
Last Modified: 2012-06-22
Hi,

I have three sets of radio button in 3 different groupID on my aspx page. If I have to do a validation so users have to select at least one from each group how do I achieve this.

Say this is what I'm doing:

 private void ServerValidate(object source, ServerValidateEventArgs args)
 {
     if (rdbLeveltwo.Checked == false && rdbLevelthree.Checked == false
               && rdbLevel23.Checked == false && rdbLevelfour.Checked == false && rdbLevel34.Checked == false)
     {
         args.IsValid = false;
     }
     else
     {
         args.IsValid = true;
     }
 }

This will validate one group and I can give the error message specific to this group that's fine. However, how do I handle the next two group and most importantly error messages specific to those group as I have set this error message already specific to the group1.

Please someone advice me!

Thanks in advance!
0
Comment
Question by:ube100
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 21

Accepted Solution

by:
masterpass earned 500 total points
ID: 37798722
option 1

Use a radiobuttonlist with a required field validator
eg: http://asp-net-example.blogspot.co.nz/2009/02/aspnet-requiredfieldvalidator-example.html

option 2

have 3 customvalidators for three groups of radiobuttons. This way you can have three distinct message for each group

Hope this helps!
0
 
LVL 7

Expert Comment

by:dhawalseth
ID: 37801340
i believe you can use jquery for your need. better option.
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

687 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question