Solved

Question on the ClientValidationFunction of CustomValidator

Posted on 2006-07-19
3
699 Views
Last Modified: 2011-10-03
function B works as expected. However function A always invalidate the checkbox status (it always think that the checkbox is unchecked.)

Anyone may offer some ideas?

function A:
function ValidateChkLegalText(sender, args)
{    var e = document.getElementById('<% =ChkLegalTextClientID %>');
    args.IsValid = e.Checked;
}

function B:
function ValidateChkLegalText(sender, args)
{
    args.IsValid = document.getElementById('<% =ChkLegalTextClientID %>').checked;
}

                        <asp:CheckBox ID="chkLegalText" runat="server"
                            Text="Checkbox text goes here."
                            ValidationGroup="Approve"  />

            <asp:CustomValidator ID="custValidatorChkBox" runat="server" ErrorMessage="Error: Checkbox is required." ValidationGroup="Approve" ClientValidationFunction="ValidateChkLegalText" Display="None"></asp:CustomValidator><br />
0
Comment
Question by:chuang4630
  • 2
3 Comments
 
LVL 23

Accepted Solution

by:
adathelad earned 500 total points
Comment Utility
Hi chuang4630,

Could be that as Javascript is case sensitice you need "checked" with a lowercase c in function A, as per function B:
args.IsValid = e.checked;
0
 
LVL 1

Author Comment

by:chuang4630
Comment Utility
Hmm, let me try
0
 
LVL 1

Author Comment

by:chuang4630
Comment Utility
Yah, you are right.

Thanks.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now