Solved

Question on the ClientValidationFunction of CustomValidator

Posted on 2006-07-19
3
702 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

749 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