<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: How to Add Hints &amp; Auto Focus Form Fields using jQuery</title>
	<atom:link href="http://www.ajaxblender.com/howto-add-hints-form-auto-focus-using-javascript.html/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ajaxblender.com/howto-add-hints-form-auto-focus-using-javascript.html</link>
	<description>A Whole Lot of AJAX!</description>
	<lastBuildDate>Tue, 10 Jan 2012 16:11:09 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Jd</title>
		<link>http://www.ajaxblender.com/howto-add-hints-form-auto-focus-using-javascript.html/comment-page-1#comment-2922</link>
		<dc:creator>Jd</dc:creator>
		<pubDate>Wed, 26 Oct 2011 19:22:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.ajaxblender.com/?p=1128#comment-2922</guid>
		<description>this is not good code, since it inputs the title as a Value and gets submitted</description>
		<content:encoded><![CDATA[<p>this is not good code, since it inputs the title as a Value and gets submitted</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff</title>
		<link>http://www.ajaxblender.com/howto-add-hints-form-auto-focus-using-javascript.html/comment-page-1#comment-1942</link>
		<dc:creator>Jeff</dc:creator>
		<pubDate>Thu, 18 Aug 2011 17:20:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.ajaxblender.com/?p=1128#comment-1942</guid>
		<description>I have a CMS that uses mootools and when I add the handle focus / blur events, I get JavaScript errors and I can&#039;t figure out how to fix.

I added the noConflict function but I still get the errors.

Here is my code:

...

{literal}
    //no conflict jquery
    jQuery.noConflict();
    //jquery stuff
    (function($) {
      $(&#039;.auto-focus:first&#039;).focus();
	  $(&#039;TEXTAREA.auto-hint&#039;).focus(function(){
			if($(this).val() == $(this).attr(&#039;title&#039;)){
				$(this).val(&#039;&#039;);
				$(this).removeClass(&#039;auto-hint&#039;);
			}
		});	  
	  $(&#039;TEXTAREA.auto-hint&#039;).blur(function(){
			if($(this).val() == &#039;&#039; &amp;&amp; $(this).attr(&#039;title&#039;) != &#039;&#039;){
			   $(this).val($(this).attr(&#039;title&#039;));
			   $(this).addClass(&#039;auto-hint&#039;);
			}
		});
	})(jQuery);
	{/literal}
  
...

Here are the errors:

...
Message: Expected &#039;)&#039;
Line: 628
Char: 31
Code: 0
URI: http://www.mysite.com/mypage.php


Message: Object doesn&#039;t support this property or method
Line: 1
Char: 20118
Code: 0
URI: http://www.mysite.com/js/mootools12-min.js


Message: Object doesn&#039;t support this property or method
Line: 65
Char: 5
Code: 0
URI: http://www.mysite.com/mypage.php
...

In my head tag, the script include for mootools comes before the jquery include. I can&#039;t change that because that would mean I would have to add the jquery include to the header template which would add jquery to every web site page. I only want jquery on this particular page so I used a Smarty capture to add the jquery include to the head tag of this page.

Anyone have any ideas?</description>
		<content:encoded><![CDATA[<p>I have a CMS that uses mootools and when I add the handle focus / blur events, I get JavaScript errors and I can&#8217;t figure out how to fix.</p>
<p>I added the noConflict function but I still get the errors.</p>
<p>Here is my code:</p>
<p>&#8230;</p>
<p>{literal}<br />
    //no conflict jquery<br />
    jQuery.noConflict();<br />
    //jquery stuff<br />
    (function($) {<br />
      $(&#8217;.auto-focus:first&#8217;).focus();<br />
	  $(&#8217;TEXTAREA.auto-hint&#8217;).focus(function(){<br />
			if($(this).val() == $(this).attr(&#8217;title&#8217;)){<br />
				$(this).val(&#8221;);<br />
				$(this).removeClass(&#8217;auto-hint&#8217;);<br />
			}<br />
		});<br />
	  $(&#8217;TEXTAREA.auto-hint&#8217;).blur(function(){<br />
			if($(this).val() == &#8221; &amp;&amp; $(this).attr(&#8217;title&#8217;) != &#8221;){<br />
			   $(this).val($(this).attr(&#8217;title&#8217;));<br />
			   $(this).addClass(&#8217;auto-hint&#8217;);<br />
			}<br />
		});<br />
	})(jQuery);<br />
	{/literal}</p>
<p>&#8230;</p>
<p>Here are the errors:</p>
<p>&#8230;<br />
Message: Expected &#8216;)&#8217;<br />
Line: 628<br />
Char: 31<br />
Code: 0<br />
URI: <a href="http://www.mysite.com/mypage.php" rel="nofollow">http://www.mysite.com/mypage.php</a></p>
<p>Message: Object doesn&#8217;t support this property or method<br />
Line: 1<br />
Char: 20118<br />
Code: 0<br />
URI: <a href="http://www.mysite.com/js/mootools12-min.js" rel="nofollow">http://www.mysite.com/js/mootools12-min.js</a></p>
<p>Message: Object doesn&#8217;t support this property or method<br />
Line: 65<br />
Char: 5<br />
Code: 0<br />
URI: <a href="http://www.mysite.com/mypage.php" rel="nofollow">http://www.mysite.com/mypage.php</a><br />
&#8230;</p>
<p>In my head tag, the script include for mootools comes before the jquery include. I can&#8217;t change that because that would mean I would have to add the jquery include to the header template which would add jquery to every web site page. I only want jquery on this particular page so I used a Smarty capture to add the jquery include to the head tag of this page.</p>
<p>Anyone have any ideas?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://www.ajaxblender.com/howto-add-hints-form-auto-focus-using-javascript.html/comment-page-1#comment-1566</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Fri, 24 Jun 2011 14:10:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.ajaxblender.com/?p=1128#comment-1566</guid>
		<description>Useful script, thanks.</description>
		<content:encoded><![CDATA[<p>Useful script, thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thomas</title>
		<link>http://www.ajaxblender.com/howto-add-hints-form-auto-focus-using-javascript.html/comment-page-1#comment-1164</link>
		<dc:creator>Thomas</dc:creator>
		<pubDate>Mon, 02 May 2011 17:02:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.ajaxblender.com/?p=1128#comment-1164</guid>
		<description>Thanks for this helpful script, I have used it 3 times already.  Also a classy way to handle someone so rude.  I will follow this blog because of that.</description>
		<content:encoded><![CDATA[<p>Thanks for this helpful script, I have used it 3 times already.  Also a classy way to handle someone so rude.  I will follow this blog because of that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Phil</title>
		<link>http://www.ajaxblender.com/howto-add-hints-form-auto-focus-using-javascript.html/comment-page-1#comment-1105</link>
		<dc:creator>Phil</dc:creator>
		<pubDate>Wed, 20 Apr 2011 10:22:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.ajaxblender.com/?p=1128#comment-1105</guid>
		<description>Here is how to clear the fields that have the title set as the content. Just make sure your title can&#039;t be a possible value a user might enter:


  $(&#039;form&#039;).submit(function(){
    $(&#039;.auto-hint&#039;).each(function(){
      if($(this).attr(&#039;title&#039;) == $(this).val()){
        $(this).val(&#039;&#039;);
      }
    });
  });</description>
		<content:encoded><![CDATA[<p>Here is how to clear the fields that have the title set as the content. Just make sure your title can&#8217;t be a possible value a user might enter:</p>
<p>  $(&#8217;form&#8217;).submit(function(){<br />
    $(&#8217;.auto-hint&#8217;).each(function(){<br />
      if($(this).attr(&#8217;title&#8217;) == $(this).val()){<br />
        $(this).val(&#8221;);<br />
      }<br />
    });<br />
  });</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Phil</title>
		<link>http://www.ajaxblender.com/howto-add-hints-form-auto-focus-using-javascript.html/comment-page-1#comment-1104</link>
		<dc:creator>Phil</dc:creator>
		<pubDate>Wed, 20 Apr 2011 10:13:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.ajaxblender.com/?p=1128#comment-1104</guid>
		<description>And by &amp; &amp; I meant:
    
    &amp; &amp;

Or if that doesn&#039;t show then HTML entity escaped ampersands.</description>
		<content:encoded><![CDATA[<p>And by &amp; &amp; I meant:</p>
<p>    &amp; &amp;</p>
<p>Or if that doesn&#8217;t show then HTML entity escaped ampersands.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Phil</title>
		<link>http://www.ajaxblender.com/howto-add-hints-form-auto-focus-using-javascript.html/comment-page-1#comment-1103</link>
		<dc:creator>Phil</dc:creator>
		<pubDate>Wed, 20 Apr 2011 10:11:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.ajaxblender.com/?p=1128#comment-1103</guid>
		<description>Couple of issues with this:

1. You&#039;ve got &amp; &amp; in your source code which should obviously be a logical and.
2. When submitting the form, if any of the fields have not been filled they will contain the default text. A bit of extra JS is needed to remove it on submission.</description>
		<content:encoded><![CDATA[<p>Couple of issues with this:</p>
<p>1. You&#8217;ve got &amp; &amp; in your source code which should obviously be a logical and.<br />
2. When submitting the form, if any of the fields have not been filled they will contain the default text. A bit of extra JS is needed to remove it on submission.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mitziman</title>
		<link>http://www.ajaxblender.com/howto-add-hints-form-auto-focus-using-javascript.html/comment-page-1#comment-998</link>
		<dc:creator>Mitziman</dc:creator>
		<pubDate>Wed, 16 Mar 2011 20:48:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.ajaxblender.com/?p=1128#comment-998</guid>
		<description>hey,

your jquery snippets got mixed up a little.</description>
		<content:encoded><![CDATA[<p>hey,</p>
<p>your jquery snippets got mixed up a little.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Mounce</title>
		<link>http://www.ajaxblender.com/howto-add-hints-form-auto-focus-using-javascript.html/comment-page-1#comment-993</link>
		<dc:creator>Peter Mounce</dc:creator>
		<pubDate>Fri, 11 Mar 2011 15:10:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.ajaxblender.com/?p=1128#comment-993</guid>
		<description>Hey - thanks for the snippet - simple and to the point and precisely what I needed at short notice.</description>
		<content:encoded><![CDATA[<p>Hey &#8211; thanks for the snippet &#8211; simple and to the point and precisely what I needed at short notice.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ajaxBlender.com</title>
		<link>http://www.ajaxblender.com/howto-add-hints-form-auto-focus-using-javascript.html/comment-page-1#comment-641</link>
		<dc:creator>ajaxBlender.com</dc:creator>
		<pubDate>Wed, 23 Jun 2010 16:31:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.ajaxblender.com/?p=1128#comment-641</guid>
		<description>rp,

From the tone of your comment, I can see you must be a valuable addition to any online community. Welcome to ajaxBlender! :p

Anyway, you probably didn’t realize that this selector is done in jQuery. The code will find the first input field with the &#039;auto-focus&#039; class and focus it, so that the user will not have to click the field with the mouse to start typing. This method is a MUST for a user-friendly web page containing forms.

Thank you for your response, though.

Alex</description>
		<content:encoded><![CDATA[<p>rp,</p>
<p>From the tone of your comment, I can see you must be a valuable addition to any online community. Welcome to ajaxBlender! :p</p>
<p>Anyway, you probably didn’t realize that this selector is done in jQuery. The code will find the first input field with the &#8216;auto-focus&#8217; class and focus it, so that the user will not have to click the field with the mouse to start typing. This method is a MUST for a user-friendly web page containing forms.</p>
<p>Thank you for your response, though.</p>
<p>Alex</p>
]]></content:encoded>
	</item>
</channel>
</rss>

