473,378 Members | 1,426 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,378 software developers and data experts.

Radio button validation

Hi,

I am having a slight problem validating radio buttons using customvalidator.

My buttons generated HTML look like...
<input id="MemberPage_MinorWorks_SpareLoadYesRadioButton " type="radio"
name="MemberPage:MinorWorks:SpareLoadCapacity"
value="SpareLoadYesRadioButton" />

<input id="MemberPage_MinorWorks_SpareLoadNoRadioButton" type="radio"
name="MemberPage:MinorWorks:SpareLoadCapacity"
value="SpareLoadNoRadioButton" />

In my JS, I have...

function CircuitTestedCheck(oSrc, args){
if(document.all['<%=SpareLoadYesRadioButton.ClientID%>'].checked == false
&& document.all['<%=SpareLoadNoRadioButton.ClientID%>'].checked == false){
args.IsValid = false;
}
else
{
args.IsValid = true;
}
}

which is referenced by the custom validator.

The ClientID when generated follows the ID not the name of the control, but
I think the JS will require the name, which looks very different.

I was doing exactly this for checkboxes. What should I do for the radio
buttons?

Thanks.

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
May 25 '07 #1
2 8116
Use document.getElementById instead of document.all
--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

"David" <da*****************@revilloc.REMOVETHIS.comwrot e in message
news:eE**************@TK2MSFTNGP04.phx.gbl...
Hi,

I am having a slight problem validating radio buttons using
customvalidator.

My buttons generated HTML look like...
<input id="MemberPage_MinorWorks_SpareLoadYesRadioButton " type="radio"
name="MemberPage:MinorWorks:SpareLoadCapacity"
value="SpareLoadYesRadioButton" />

<input id="MemberPage_MinorWorks_SpareLoadNoRadioButton" type="radio"
name="MemberPage:MinorWorks:SpareLoadCapacity"
value="SpareLoadNoRadioButton" />

In my JS, I have...

function CircuitTestedCheck(oSrc, args){
if(document.all['<%=SpareLoadYesRadioButton.ClientID%>'].checked == false
&& document.all['<%=SpareLoadNoRadioButton.ClientID%>'].checked == false){
args.IsValid = false;
}
else
{
args.IsValid = true;
}
}

which is referenced by the custom validator.

The ClientID when generated follows the ID not the name of the control,
but I think the JS will require the name, which looks very different.

I was doing exactly this for checkboxes. What should I do for the radio
buttons?

Thanks.

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available

May 26 '07 #2
Of course...

Why didn't I think of that. I will try it.

Thank you.
--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
"Teemu Keiski" <jo****@aspalliance.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Use document.getElementById instead of document.all
--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

"David" <da*****************@revilloc.REMOVETHIS.comwrot e in message
news:eE**************@TK2MSFTNGP04.phx.gbl...
>Hi,

I am having a slight problem validating radio buttons using
customvalidator.

My buttons generated HTML look like...
<input id="MemberPage_MinorWorks_SpareLoadYesRadioButton " type="radio"
name="MemberPage:MinorWorks:SpareLoadCapacity"
value="SpareLoadYesRadioButton" />

<input id="MemberPage_MinorWorks_SpareLoadNoRadioButton" type="radio"
name="MemberPage:MinorWorks:SpareLoadCapacity"
value="SpareLoadNoRadioButton" />

In my JS, I have...

function CircuitTestedCheck(oSrc, args){
if(document.all['<%=SpareLoadYesRadioButton.ClientID%>'].checked ==
false && document.all['<%=SpareLoadNoRadioButton.ClientID%>'].checked ==
false){
args.IsValid = false;
}
else
{
args.IsValid = true;
}
}

which is referenced by the custom validator.

The ClientID when generated follows the ID not the name of the control,
but I think the JS will require the name, which looks very different.

I was doing exactly this for checkboxes. What should I do for the radio
buttons?

Thanks.

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available


May 26 '07 #3

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

Similar topics

10
by: DettCom | last post by:
Hello, I would like to be able to display or hide fields based on whether a specific Yes/No radio button is selected. This is in conjunction with a posting a just made here in the same group...
8
by: David Cameron | last post by:
I noticed that using an HTMLInputRadioButton and specifying a value to be an empty string (""), this is overridden by ASP.Net which set the value of the control to be the same as the ID of the...
6
by: Blinky | last post by:
Hi all, I have a dynamically generated page that can have 1 or more radio buttons. I am using javascript with onsubmit in the form statement to make sure a radio button is selected before...
9
by: wreed | last post by:
I have a for loop seen below.... var the_form = document.getElementById(formName); for(var i=0; i<the_form.length; i++) { var temp = the_form.elements.type; if (temp == "radio") { for (x =...
1
by: Jerim79 | last post by:
I have a simple 3 page registration form. One form, one "data validation" script and one "insert into database" script. The customer bounces back and forth from the form to the verification script...
5
by: swatidesai0407 | last post by:
hi im validating radio buttons i create dis radio button in php based on some how many records of my query. i wrote a javascript to validate this buttons. wat i do is dat wen no radio button...
0
by: Gary W. Smith | last post by:
Hello, I have a simple form with a radio button group on it and I need to do some basic validation based upon which button is checked. Here is a little more detail. if button one is...
8
by: photoboy | last post by:
I have racked by brain long enough on this, so now I need the help of someone who knows what they are doing. Here is what I am trying to achieve: First, I have two radio buttons (both unchecked)...
4
by: pureadrenaline | last post by:
Hey Guys, Please could anyone help me out with the following form I need to create a validation on the email field only if the user checked the radio button named Email. Thanks in advance. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.