<?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: jQuery Plugin &#8211; Form Field Default Value</title>
	<atom:link href="http://www.jason-palmer.com/2008/08/jquery-plugin-form-field-default-value/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jason-palmer.com/2008/08/jquery-plugin-form-field-default-value/</link>
	<description></description>
	<lastBuildDate>Thu, 04 Feb 2010 00:45:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Todd</title>
		<link>http://www.jason-palmer.com/2008/08/jquery-plugin-form-field-default-value/comment-page-1/#comment-342</link>
		<dc:creator>Todd</dc:creator>
		<pubDate>Thu, 04 Feb 2010 00:45:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.jason-palmer.com/?p=7#comment-342</guid>
		<description>Thanks for the code Jason.  Made a few updates to it so it would work with our project.
- Fixed refresh bug
- Fixed plugin bug so it will work with jQuery’s noconflict mode
- Added trim so it will remove whitespace in the fields and show the default values if there is only whitespace
- Added the class support from SKaRCHa (fixed refresh class update bug)

===========================
(function($) {
	String.prototype.trim = function() {
		return this.replace(/^\s+&#124;\s+$/g,&quot;&quot;);
	}
	$.fn.DefaultValue = function(klass,text) {
		return this.each(function() {
			//Make sure we&#039;re dealing with text-based form fields
			if (this.type != &#039;text&#039; &amp;&amp; this.type != &#039;password&#039; &amp;&amp; this.type != &#039;textarea&#039;) {
				return;
			}
			
			//Store field reference
			var fld_current = this;
			var fldVal = this.value.toLowerCase().trim();
			var textVal = text.toLowerCase().trim();
			
			//Set value initially if none are specified
			if (fldVal == textVal &#124;&#124; fldVal == &#039;&#039;) {
				$(this).addClass(klass);
				this.value = text;
			}
			
			//Remove values on focus
			$(this).focus(function() {
				var fldVal = this.value.toLowerCase().trim();
				if (fldVal == textVal &#124;&#124; fldVal == &#039;&#039;) {
					this.value = &#039;&#039;;
					$(this).removeClass(klass);
				}
			});
			
			//Place values back on blur
			$(this).blur(function() {
				var fldVal = this.value.toLowerCase().trim();
				if (fldVal == textVal &#124;&#124; fldVal == &#039;&#039;) {
					$(this).addClass(klass);
					this.value = text;
				}
			});
			
			//Capture parent form submission
			//Remove field values that are still default
			$(this).parents(&quot;form&quot;).each(function() {
				//Bind parent form submit
				$(this).submit(function() {
					if (fld_current.value.toLowerCase().trim() == textVal) {
						fld_current.value = &#039;&#039;;
					}
				});
			});
	    });
	};
})(jQuery);
===========================</description>
		<content:encoded><![CDATA[<p>Thanks for the code Jason.  Made a few updates to it so it would work with our project.<br />
- Fixed refresh bug<br />
- Fixed plugin bug so it will work with jQuery’s noconflict mode<br />
- Added trim so it will remove whitespace in the fields and show the default values if there is only whitespace<br />
- Added the class support from SKaRCHa (fixed refresh class update bug)</p>
<p>===========================<br />
(function($) {<br />
	String.prototype.trim = function() {<br />
		return this.replace(/^\s+|\s+$/g,&#8221;");<br />
	}<br />
	$.fn.DefaultValue = function(klass,text) {<br />
		return this.each(function() {<br />
			//Make sure we&#8217;re dealing with text-based form fields<br />
			if (this.type != &#8216;text&#8217; &amp;&amp; this.type != &#8216;password&#8217; &amp;&amp; this.type != &#8216;textarea&#8217;) {<br />
				return;<br />
			}</p>
<p>			//Store field reference<br />
			var fld_current = this;<br />
			var fldVal = this.value.toLowerCase().trim();<br />
			var textVal = text.toLowerCase().trim();</p>
<p>			//Set value initially if none are specified<br />
			if (fldVal == textVal || fldVal == &#8221;) {<br />
				$(this).addClass(klass);<br />
				this.value = text;<br />
			}</p>
<p>			//Remove values on focus<br />
			$(this).focus(function() {<br />
				var fldVal = this.value.toLowerCase().trim();<br />
				if (fldVal == textVal || fldVal == &#8221;) {<br />
					this.value = &#8221;;<br />
					$(this).removeClass(klass);<br />
				}<br />
			});</p>
<p>			//Place values back on blur<br />
			$(this).blur(function() {<br />
				var fldVal = this.value.toLowerCase().trim();<br />
				if (fldVal == textVal || fldVal == &#8221;) {<br />
					$(this).addClass(klass);<br />
					this.value = text;<br />
				}<br />
			});</p>
<p>			//Capture parent form submission<br />
			//Remove field values that are still default<br />
			$(this).parents(&#8220;form&#8221;).each(function() {<br />
				//Bind parent form submit<br />
				$(this).submit(function() {<br />
					if (fld_current.value.toLowerCase().trim() == textVal) {<br />
						fld_current.value = &#8221;;<br />
					}<br />
				});<br />
			});<br />
	    });<br />
	};<br />
})(jQuery);<br />
===========================</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SKaRCHa</title>
		<link>http://www.jason-palmer.com/2008/08/jquery-plugin-form-field-default-value/comment-page-1/#comment-283</link>
		<dc:creator>SKaRCHa</dc:creator>
		<pubDate>Tue, 01 Sep 2009 12:30:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.jason-palmer.com/?p=7#comment-283</guid>
		<description>We are not using in the website, but in web application (Cherokee-Admin) to configure Cherokee web server.

I&#039;ll be tuned... Thanks again! ;)</description>
		<content:encoded><![CDATA[<p>We are not using in the website, but in web application (Cherokee-Admin) to configure Cherokee web server.</p>
<p>I&#8217;ll be tuned&#8230; Thanks again! <img src='http://www.jason-palmer.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason</title>
		<link>http://www.jason-palmer.com/2008/08/jquery-plugin-form-field-default-value/comment-page-1/#comment-282</link>
		<dc:creator>Jason</dc:creator>
		<pubDate>Mon, 31 Aug 2009 19:30:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.jason-palmer.com/?p=7#comment-282</guid>
		<description>Hi SKaRCHa,

It&#039;s great to hear that you&#039;re using it for your site.  BTW, the cherokee project looks very promising!

As you can see, several developers have created updates to the plugin over the past few months.  In the next few weeks, I&#039;ll be updating the plugin with some of these features/fixes.

Check back soon!</description>
		<content:encoded><![CDATA[<p>Hi SKaRCHa,</p>
<p>It&#8217;s great to hear that you&#8217;re using it for your site.  BTW, the cherokee project looks very promising!</p>
<p>As you can see, several developers have created updates to the plugin over the past few months.  In the next few weeks, I&#8217;ll be updating the plugin with some of these features/fixes.</p>
<p>Check back soon!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SKaRCHa</title>
		<link>http://www.jason-palmer.com/2008/08/jquery-plugin-form-field-default-value/comment-page-1/#comment-281</link>
		<dc:creator>SKaRCHa</dc:creator>
		<pubDate>Sun, 30 Aug 2009 18:37:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.jason-palmer.com/?p=7#comment-281</guid>
		<description>Jason, thanks for sharing this code... We just start using a modified version of your plugin in Cherokee-Admin (http://www.cherokee-project.com)

This is the modified version. I have added a new parameter (class) to change the class of the input element.

jQuery.fn.DefaultValue = function(klass, text){
	return this.each(function(){
		//Make sure we&#039;re dealing with text-based form fields
		if (this.type != &#039;text&#039; &amp;&amp; this.type != &#039;password&#039; &amp;&amp; this.type != &#039;textarea&#039;)
			return;

		//Store field reference
		var fld_current = this;

		//Set value initially if none are specified
		if($(this).val() == &#039;&#039;) {
			$(this).val(text);
		} else {
			//Other value exists - ignore
			return;
		}

		//Remove values on focus
		$(this).focus(function() {
			if($(this).val() == text &#124;&#124; $(this).val() == &#039;&#039;) {
				$(this).removeClass(klass);
				$(this).val(&#039;&#039;);
			}
		});

		//Place values back on blur
		$(this).blur(function() {
			if($(this).val() == text &#124;&#124; $(this).val() == &#039;&#039;) {
				$(this).addClass(klass);
				$(this).val(text);
			}
		});

		//Capture parent form submission
		//Remove field values that are still default
		$(this).parents(&quot;form&quot;).each(function() {
			//Bind parent form submit
			$(this).submit(function() {
				if($(fld_current).val() == text) {
					$(fld_current).val(&#039;&#039;);
				}
			});
		});
    });
};</description>
		<content:encoded><![CDATA[<p>Jason, thanks for sharing this code&#8230; We just start using a modified version of your plugin in Cherokee-Admin (<a href="http://www.cherokee-project.com" rel="nofollow">http://www.cherokee-project.com</a>)</p>
<p>This is the modified version. I have added a new parameter (class) to change the class of the input element.</p>
<p>jQuery.fn.DefaultValue = function(klass, text){<br />
	return this.each(function(){<br />
		//Make sure we&#8217;re dealing with text-based form fields<br />
		if (this.type != &#8216;text&#8217; &amp;&amp; this.type != &#8216;password&#8217; &amp;&amp; this.type != &#8216;textarea&#8217;)<br />
			return;</p>
<p>		//Store field reference<br />
		var fld_current = this;</p>
<p>		//Set value initially if none are specified<br />
		if($(this).val() == &#8221;) {<br />
			$(this).val(text);<br />
		} else {<br />
			//Other value exists &#8211; ignore<br />
			return;<br />
		}</p>
<p>		//Remove values on focus<br />
		$(this).focus(function() {<br />
			if($(this).val() == text || $(this).val() == &#8221;) {<br />
				$(this).removeClass(klass);<br />
				$(this).val(&#8221;);<br />
			}<br />
		});</p>
<p>		//Place values back on blur<br />
		$(this).blur(function() {<br />
			if($(this).val() == text || $(this).val() == &#8221;) {<br />
				$(this).addClass(klass);<br />
				$(this).val(text);<br />
			}<br />
		});</p>
<p>		//Capture parent form submission<br />
		//Remove field values that are still default<br />
		$(this).parents(&#8220;form&#8221;).each(function() {<br />
			//Bind parent form submit<br />
			$(this).submit(function() {<br />
				if($(fld_current).val() == text) {<br />
					$(fld_current).val(&#8221;);<br />
				}<br />
			});<br />
		});<br />
    });<br />
};</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: phil</title>
		<link>http://www.jason-palmer.com/2008/08/jquery-plugin-form-field-default-value/comment-page-1/#comment-279</link>
		<dc:creator>phil</dc:creator>
		<pubDate>Mon, 10 Aug 2009 10:57:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.jason-palmer.com/?p=7#comment-279</guid>
		<description>great plugin Jason this is just what I was looking for! Nice work!</description>
		<content:encoded><![CDATA[<p>great plugin Jason this is just what I was looking for! Nice work!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: satya</title>
		<link>http://www.jason-palmer.com/2008/08/jquery-plugin-form-field-default-value/comment-page-1/#comment-271</link>
		<dc:creator>satya</dc:creator>
		<pubDate>Sun, 19 Jul 2009 11:48:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.jason-palmer.com/?p=7#comment-271</guid>
		<description>Tx jason. Nice n nifty. Well, i read d comments n realized reg the problem wid password field. Lucky me, im not using it in a login form ;). Anyways, lemme know once if the password-problem is fixed. I have a bunch of developers im guiding, i would love to pass this onto them.</description>
		<content:encoded><![CDATA[<p>Tx jason. Nice n nifty. Well, i read d comments n realized reg the problem wid password field. Lucky me, im not using it in a login form <img src='http://www.jason-palmer.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> . Anyways, lemme know once if the password-problem is fixed. I have a bunch of developers im guiding, i would love to pass this onto them.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Clark</title>
		<link>http://www.jason-palmer.com/2008/08/jquery-plugin-form-field-default-value/comment-page-1/#comment-236</link>
		<dc:creator>Clark</dc:creator>
		<pubDate>Thu, 28 May 2009 22:32:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.jason-palmer.com/?p=7#comment-236</guid>
		<description>Jason,  Great plugin man!  Really helps for sites that use a lot of inputs and need default text in them.  Little bug in firefox though.  If you go to a page, on first load it works, but if you simply refresh it not longer works (just a firefox thing).  

Fixing it is easy, on this line:

//Set value initially if none are specified
        if(this.value==&#039;&#039;) {

Just add:

//Set value initially if none are specified
        if(this.value==&#039;&#039; &#124;&#124; this.value == text) {

Boom fixed and works great in all browsers!</description>
		<content:encoded><![CDATA[<p>Jason,  Great plugin man!  Really helps for sites that use a lot of inputs and need default text in them.  Little bug in firefox though.  If you go to a page, on first load it works, but if you simply refresh it not longer works (just a firefox thing).  </p>
<p>Fixing it is easy, on this line:</p>
<p>//Set value initially if none are specified<br />
        if(this.value==&#8221;) {</p>
<p>Just add:</p>
<p>//Set value initially if none are specified<br />
        if(this.value==&#8221; || this.value == text) {</p>
<p>Boom fixed and works great in all browsers!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: William</title>
		<link>http://www.jason-palmer.com/2008/08/jquery-plugin-form-field-default-value/comment-page-1/#comment-170</link>
		<dc:creator>William</dc:creator>
		<pubDate>Sat, 02 May 2009 13:23:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.jason-palmer.com/?p=7#comment-170</guid>
		<description>OMG! Thx Dude, just what i needed :-)</description>
		<content:encoded><![CDATA[<p>OMG! Thx Dude, just what i needed <img src='http://www.jason-palmer.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robby</title>
		<link>http://www.jason-palmer.com/2008/08/jquery-plugin-form-field-default-value/comment-page-1/#comment-109</link>
		<dc:creator>Robby</dc:creator>
		<pubDate>Wed, 11 Mar 2009 19:29:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.jason-palmer.com/?p=7#comment-109</guid>
		<description>Jason,
Great plugin, It&#039;s a nice little utility that just saved me some time under a tight deadline. Thanks for sharing.

Two little nitpicks,
1. It fails if you&#039;re using it with jQuery&#039;s noconflict mode. That&#039;s easily fixed by changing all instances of &#039;$(&#039; to &#039;jQuery(&#039;.

2. There&#039;s an edge case where someone will put a value in a field, refresh the page (their inputted value is retained), and then the focus and blur actions are not applied. You can fix this by removing the &#039;return&#039; statement on line 15. I dont&#039; think it&#039;s needed for anything else, unless you explicitly didn&#039;t want to add the focus and blur handlers for some reason.

Anyways, thanks again!</description>
		<content:encoded><![CDATA[<p>Jason,<br />
Great plugin, It&#8217;s a nice little utility that just saved me some time under a tight deadline. Thanks for sharing.</p>
<p>Two little nitpicks,<br />
1. It fails if you&#8217;re using it with jQuery&#8217;s noconflict mode. That&#8217;s easily fixed by changing all instances of &#8216;$(&#8216; to &#8216;jQuery(&#8216;.</p>
<p>2. There&#8217;s an edge case where someone will put a value in a field, refresh the page (their inputted value is retained), and then the focus and blur actions are not applied. You can fix this by removing the &#8216;return&#8217; statement on line 15. I dont&#8217; think it&#8217;s needed for anything else, unless you explicitly didn&#8217;t want to add the focus and blur handlers for some reason.</p>
<p>Anyways, thanks again!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brett</title>
		<link>http://www.jason-palmer.com/2008/08/jquery-plugin-form-field-default-value/comment-page-1/#comment-103</link>
		<dc:creator>Brett</dc:creator>
		<pubDate>Fri, 16 Jan 2009 22:56:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.jason-palmer.com/?p=7#comment-103</guid>
		<description>Actually... I just realized that it&#039;s best to initiate the gray from within the script too:


		//Set value initially if none are specified
        if(this.value==text &#124;&#124; this.value==&#039;&#039;) {
			this.value=text;
			$(this).css({&#039;color&#039; : &#039;gray&#039;});
		}
		
		//Remove values on focus
		$(this).focus(function() {
			if(this.value==text &#124;&#124; this.value==&#039;&#039;){
				this.value=&#039;&#039;;
				$(this).css({&#039;color&#039; : &#039;black&#039;});
}
		});
		
		//Place values back on blur
		$(this).blur(function() {
			if(this.value==text &#124;&#124; this.value==&#039;&#039;){
				this.value=text;
				$(this).css({&#039;color&#039; : &#039;gray&#039;});
			}
		});</description>
		<content:encoded><![CDATA[<p>Actually&#8230; I just realized that it&#8217;s best to initiate the gray from within the script too:</p>
<p>		//Set value initially if none are specified<br />
        if(this.value==text || this.value==&#8221;) {<br />
			this.value=text;<br />
			$(this).css({&#8216;color&#8217; : &#8216;gray&#8217;});<br />
		}</p>
<p>		//Remove values on focus<br />
		$(this).focus(function() {<br />
			if(this.value==text || this.value==&#8221;){<br />
				this.value=&#8221;;<br />
				$(this).css({&#8216;color&#8217; : &#8216;black&#8217;});<br />
}<br />
		});</p>
<p>		//Place values back on blur<br />
		$(this).blur(function() {<br />
			if(this.value==text || this.value==&#8221;){<br />
				this.value=text;<br />
				$(this).css({&#8216;color&#8217; : &#8216;gray&#8217;});<br />
			}<br />
		});</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.387 seconds -->
<!-- Cached page served by WP-Cache -->
