Solved

Question on the ClientValidationFunction of CustomValidator

Posted on 2006-07-19
3
704 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 23

Accepted Solution

by:
adathelad earned 500 total points
ID: 17138717
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
ID: 17138946
Hmm, let me try
0
 
LVL 1

Author Comment

by:chuang4630
ID: 17138966
Yah, you are right.

Thanks.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

726 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