Custom field validators not firing in Firefox or Netscape

J

John Abbler

I'm currently testing doing some testing with other browsers and have found
that my custom field validators aren't firing with Firefox or Netscape, but
they work fine with Ie.

Here's the code I'm using:

<asp:CustomValidator id="vld1PaymentType"
ClientValidationFunction="ValidateRadiobutton" runat="server"
ErrorMessage="Payment Type must be selected"
CssClass="ValidationMessage"></asp:CustomValidator>

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

Am I not going about this the right way or there another way to validate a
radio button?

Thanks!
 
G

Guest

Hi John, the document.all collection is IE only so use
document.getElementById('<%= rbChoiceA.ClientId%>')

HTH jd
 
H

Hans Kesting

John said:
I'm currently testing doing some testing with other browsers and have
found that my custom field validators aren't firing with Firefox or
Netscape, but they work fine with Ie.

Do other *client side* validator work? By default Firefox isn't recognised
as "up-level" browser, so no javascript is emitted.

See http://slingfive.com/pages/code/browserCaps/

Hans Kesting
 
J

John Abbler

Hi Hans,

Thanks for the reply. I have been using the BrowserCaps enhancement.

I also a Java Script function to disable the back button that does work.

function DisableBackButton(oSrc, args) { window.history.forward(1); }

I tried changing the to the "getElementById" function.

function ValidateRadiobutton(oSrc, args) {
if(document.getElementById["<%=rbChoiceA.ClientID%>"].checked == false &&
document.getElementById["<%=rbChoiceB.ClientID%>"].checked == false){
args.IsValid = false;
}
}

Unfortunately, it's still not working yet.

Any other suggestions?

Thanks!
 
G

Guest

Firefox has tons of plugins that let you debug your client side code.
Actually, by default it has the JavaScript debugger. You just need to open
it up on your page and will tell you all of your errors.

--
Staff Consultant II
Enterprise Web Services
Cardinal Solutions Group

Future Business Model
Loan Origination Services
National City Mortgage


John Abbler said:
Hi Hans,

Thanks for the reply. I have been using the BrowserCaps enhancement.

I also a Java Script function to disable the back button that does work.

function DisableBackButton(oSrc, args) { window.history.forward(1); }

I tried changing the to the "getElementById" function.

function ValidateRadiobutton(oSrc, args) {
if(document.getElementById["<%=rbChoiceA.ClientID%>"].checked == false &&
document.getElementById["<%=rbChoiceB.ClientID%>"].checked == false){
args.IsValid = false;
}
}

Unfortunately, it's still not working yet.

Any other suggestions?

Thanks!

Hans Kesting said:
Do other *client side* validator work? By default Firefox isn't recognised
as "up-level" browser, so no javascript is emitted.

See http://slingfive.com/pages/code/browserCaps/

Hans Kesting
 
G

Guest

Hi John document.getElementById('id') note curly brackets squarebrackets []
are indexers... HTH jd

John Abbler said:
Hi Hans,

Thanks for the reply. I have been using the BrowserCaps enhancement.

I also a Java Script function to disable the back button that does work.

function DisableBackButton(oSrc, args) { window.history.forward(1); }

I tried changing the to the "getElementById" function.

function ValidateRadiobutton(oSrc, args) {
if(document.getElementById["<%=rbChoiceA.ClientID%>"].checked == false &&
document.getElementById["<%=rbChoiceB.ClientID%>"].checked == false){
args.IsValid = false;
}
}

Unfortunately, it's still not working yet.

Any other suggestions?

Thanks!

Hans Kesting said:
Do other *client side* validator work? By default Firefox isn't recognised
as "up-level" browser, so no javascript is emitted.

See http://slingfive.com/pages/code/browserCaps/

Hans Kesting
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top