Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : 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
 
Old March 31st, 2012, 01:06 PM
Registered User
 
Join Date: Mar 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help - Javascript fro Watermark

Can anyone please help correct some Javascipt? This particular script is not in the download.... it is in Chapter 11.

When I run the script, I get:

Error: '$' is undefined in the browser. (How can it be undefined??)

The code is below and seems identical to the code in the book - but I am willing to bet it has a glitch I have not found yet.

Code:
<%--Java Script to apply Watermark --%>
<script type="text/javascript">
     $(function() 
     {
          $(':input[type=text],textarea').each
          (
          function() 
          {
               var newText = 'Please enter your ' +
               $(this).parent().prev().text().toLowerCase().trim();
               $(this).attr('value', newText); 
          }).one('focus', function() 
                    {    
                         this.value = '', this.className = ''
                              }).addClass('Watermark').css('width', '300px');
     });
</script>

Last edited by pgrant; March 31st, 2012 at 01:10 PM..
 
Old March 31st, 2012, 01:17 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

The error "Error: '$' is undefined in the browser." seems to imply the jQuery library cannot be found. Did you add a reference to it in your page or master page? Can you show the code for that and describe where you placed the jQuery library .js file?

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!
 
Old March 31st, 2012, 02:37 PM
Registered User
 
Join Date: Mar 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Thank You

Imar
Thanks you are quite right, no reference. I was trying to test my understanding by putting subjects in the book into my own web site - and I missed an important step.





Similar Threads
Thread Thread Starter Forum Replies Last Post
javscript for allow enter key only in multilne textboxes sudhi ASP.NET 1.0 and 1.1 Professional 1 August 13th, 2011 09:53 AM
need to fix the size of page opened via javscript. [email protected] JSP Basics 0 August 10th, 2010 07:14 AM
VBscript boolean function causes Javscript to bomb calgarychinese Javascript 2 August 25th, 2008 03:38 PM
Javscript works well in aspx page but fails... vivek_inos ASP.NET 1.0 and 1.1 Professional 2 June 18th, 2006 11:26 PM
Masterpage to include a javscript file whatagamble ASP.NET 2.0 Basics 0 March 19th, 2006 01:09 PM





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