Validating a RadioButton Selection

S

Scott Natwick

I am having trouble validating that a selection has been made from a
RadioButton.

I created a script to trigger from a CustomValidator, however, it only works
when I run the app locally, from the debugger. Once I upload it to the
server and run, the script no longer triggers.

Any ideas?

Thanks in advance,
Scott

<script language="javascript">
function ValidateRadiobutton(oSrc, args) {
if(document.all["<%=rbChoiceA.ClientID%>"].checked == false &&
document.all["<%=rbChoiceB.ClientID%>"].checked == false &&
document.all["<%=rbChoiceC.ClientID%>"].checked == false){
args.IsValid = false;
}
}
</script>

<asp:CustomValidator id="vld1Chkbox"
ClientValidationFunction="ValidateRadiobutton" runat="server"
ErrorMessage="Selection must be made"
CssClass="ValidationMessage"></asp:CustomValidator>
 
D

Dan Bass

I had this once too...

What you need to do is copy the directory in the IIS folder called
"aspnet_client" into your application folder...
Check the file titled "WebUIValidation.js" exists here.
 
S

Scott Natwick

Dan,

Thanks for your reply! That did it.

Scott

Dan Bass said:
I had this once too...

What you need to do is copy the directory in the IIS folder called
"aspnet_client" into your application folder...
Check the file titled "WebUIValidation.js" exists here.


Scott Natwick said:
I am having trouble validating that a selection has been made from a
RadioButton.

I created a script to trigger from a CustomValidator, however, it only
works when I run the app locally, from the debugger. Once I upload it to
the server and run, the script no longer triggers.

Any ideas?

Thanks in advance,
Scott

<script language="javascript">
function ValidateRadiobutton(oSrc, args) {
if(document.all["<%=rbChoiceA.ClientID%>"].checked == false &&
document.all["<%=rbChoiceB.ClientID%>"].checked == false &&
document.all["<%=rbChoiceC.ClientID%>"].checked == false){
args.IsValid = false;
}
}
</script>

<asp:CustomValidator id="vld1Chkbox"
ClientValidationFunction="ValidateRadiobutton" runat="server"
ErrorMessage="Selection must be made"
CssClass="ValidationMessage"></asp:CustomValidator>
 

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

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,280
Latest member
BGBBrock56

Latest Threads

Top