Validating a RadioButton Selection

  • Thread starter Thread starter Scott Natwick
  • Start date Start date
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>
 
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.
 
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>
 
Back
Top