Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4.5 > BOOK: Beginning ASP.NET 4.5 : in C# and VB
Password Reminder
Register
| FAQ | Members List | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #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.
Reply With Quote
  #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.
Reply With Quote
  #3 (permalink)  
Old April 2nd, 2013, 04:01 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 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!
Reply With Quote
  #4 (permalink)  
Old April 2nd, 2013, 04:04 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 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!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 03:49 PM.


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