473,408 Members | 1,875 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

RequiredFieldValidator on RadioButtons?

I have a couple of RadioButtons both with the same GroupName. Is there
any way I can use a RequiredFieldValidator to ensure that at least one
of the RadioButtons in the group is selected? Setting ControlToValidate
to the GroupName doesn't seem to work, and obviously setting it to the
ID of one of the individual RadioButtons won't work.. any ideas?

Thanks in advance,

Chris

Dec 14 '05 #1
2 15029
Chris,

Instead of using two separate RadioButtons use the RadioButtonList control.
Then you can set the RequiredFieldValidator's ControlToValidate to the
RadioButtonList control and it will require a selection.

By the way, if you ever need a RequiredFieldValidator for a checkboxlist
I've created one that I give away for free (with source code). There is a
demo of it here:
http://www.aboutfortunate.com/defaul...tvalidatordemo
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Chris Ashley" <ch***********@gmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
I have a couple of RadioButtons both with the same GroupName. Is there
any way I can use a RequiredFieldValidator to ensure that at least one
of the RadioButtons in the group is selected? Setting ControlToValidate
to the GroupName doesn't seem to work, and obviously setting it to the
ID of one of the individual RadioButtons won't work.. any ideas?

Thanks in advance,

Chris

Dec 14 '05 #2
Chris - Radio Buttons do not support the Required Field Validator. You can
either have a button selected by default or employ javascript. Here's a
simple example that forces a user to select either a Male or Female radio
button. There are plenty of variations of this on the Internet if you do a
little digging:

if ( ( document.myForm.gender[0].checked == false ) && (
document.myForm.gender[1].checked == false ) )
{
alert ( "Please select either Male or Female" );
valid = false;
}

"Chris Ashley" <ch***********@gmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
I have a couple of RadioButtons both with the same GroupName. Is there
any way I can use a RequiredFieldValidator to ensure that at least one
of the RadioButtons in the group is selected? Setting ControlToValidate
to the GroupName doesn't seem to work, and obviously setting it to the
ID of one of the individual RadioButtons won't work.. any ideas?

Thanks in advance,

Chris

Dec 14 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: discomiller | last post by:
Mario Mueller: Hello *, radiobuttons belong to other radiobuttons by the "name="any_value"" attribut. Thats a fakt. I got the following XML:...
0
by: Nicolas | last post by:
How can I have only one RequiredFieldValidator to control two TextBox webcontrols so that only one message is displayed <asp:Label id="lbl_UserName" runat="server"></asp:Label><br> <asp:TextBox...
4
by: James | last post by:
Hello, I have a RequiredFieldValidator for several textbox controls on a form. Here's an example with the RequiredFieldValidator. EnableClientScript, Enabled, and Visible are set to true for...
5
by: Fernando Lopes | last post by:
Hi. I want to show an image in a requiredfield validator instead of "*". So, I 'm set the requiredfieldvalidator attributes like following: <asp:RequiredFieldValidator id=rfvFirstName...
1
by: --=|3s|=-- | last post by:
Hi, I'm trying to create a form in VISUAL BASIC .NET wich shows values of records from a customers table. For example a form wich shows the name, surname and sex of a person. For the name &...
4
by: news.microsoft.com | last post by:
Hello, I have two databound radiobuttons which have advanced databinding properties of onpropertychanged enabled so that I can raise the columnchanged event whenever the radiobuttons are...
2
by: Jan | last post by:
Hi, I've 2 radio buttons (Yes and No) in a radiobuttongroup grpQuestion. I want to use the required fieldvalidator to check if Yes or No is checked. How can this be done?
0
by: PaulS | last post by:
Hello! I put on Form PictureBox and I set big image. Next I put many radiobuttons (80) on PictureBox, but I have problem. I want that 10 radiobuttons have own Checked, next part of 10...
4
by: PedroVision | last post by:
I have a VB 2005 form with 140 different radiobuttons... Some are "checked", some are not... I want to reset all radiobuttons to "unchecked". I've been searching and trying differnet...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.