Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4.5 > BOOK: Beginning ASP.NET 4.5 : in C# and VB
| Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 4.5 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4.5: in C# and VB by Imar Spaanjaars; ISBN: 978-1-118-31180-6
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4.5 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old March 31st, 2013, 01:37 PM
Registered User
Points: 32, Level: 1
Points: 32, Level: 1 Points: 32, Level: 1 Points: 32, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2013
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
Default CustomValidator client validation function not working

Hi,
After reading your book, I write a small website to applied what I learned, but somehow the client validation function is not running... only the server side is running.

Below is the source view of the page on the javascript:

<script type="text/javascript">
function validateCentreName(source, args)
{
var centreNameText = document.getElementById('cpMainContent_CentreNameT ext');

if (centreNameText.value != '')
{
args.isValid = true;
alert('No Error');
}
else
{
args.isValid = false;
alert('Error');
}
}
</script>

Below is the source view of the page on the custom validation control:
<input name="ctl00$cpMainContent$CentreNameText" type="text" maxlength="100" id="cpMainContent_CentreNameText" style="width:500px;" />
<span data-val-errormessage="Enter centre name" data-val-display="Dynamic" id="cpMainContent_CentreNameValidator" class="ErrorMessage" data-val="true" data-val-evaluationfunction="CustomValidatorEvaluateIsValid " data-val-clientvalidationfunction="validateCentreName" style="display:none;">*</span>

Any idea what went wrong?

Thanks and have a nice day.
  #2 (permalink)  
Old April 1st, 2013, 09:51 AM
Authorized User
Points: 118, Level: 2
Points: 118, Level: 2 Points: 118, Level: 2 Points: 118, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2013
Posts: 29
Thanks: 1
Thanked 1 Time in 1 Post
Default

Only thing I noticed on a quick glance was this:

var centreNameText = document.getElementById('cpMainContent_CentreNameT ext');

There's a space in CentreNameText at the end.
  #3 (permalink)  
Old April 2nd, 2013, 04:01 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Same here; can't see anything wrong except for the space. If that doesn't fix it, can you post the relevant markup for the page?

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
  #4 (permalink)  
Old April 2nd, 2013, 04:04 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Oh, I think I see it. Take a look at this:

Code:
args.isValid = true;

args.isValid = false;
This should be IsValid with a capital I.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!


Similar Threads
Thread Thread Starter Forum Replies Last Post
javascript client validation check adamhw Javascript How-To 8 August 25th, 2010 09:15 AM
Client Side Validation anujrathi ASP.NET 1.0 and 1.1 Professional 1 June 17th, 2006 10:23 PM
Axis client validation rao J2EE 0 November 18th, 2005 08:47 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.