<?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:Set Maxlength of Textarea using jQuery/JavaScript</title> <atom:link href="http://viralpatel.net/blogs/2008/12/set-maxlength-of-textarea-input-using-jquery-javascript.html/feed" rel="self" type="application/rss+xml" /><link>http://viralpatel.net/blogs/2008/12/set-maxlength-of-textarea-input-using-jquery-javascript.html</link> <description>Tutorials, Java, J2EE, Struts, AJAX, JavaScript, CSS, Web 2.0, MySQL, Articles</description> <lastBuildDate>Wed, 08 Feb 2012 10:36:26 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>By: mike</title><link>http://viralpatel.net/blogs/2008/12/set-maxlength-of-textarea-input-using-jquery-javascript.html/comment-page-1#comment-25771</link> <dc:creator>mike</dc:creator> <pubDate>Wed, 01 Feb 2012 19:12:56 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=162#comment-25771</guid> <description>Do you know how to deal if they copy from cliboard data your Jquery code doesn&#039;t handle it. Thanks</description> <content:encoded><![CDATA[<p>Do you know how to deal if they copy from cliboard data your Jquery code doesn&#8217;t handle it.<br /> Thanks</p> ]]></content:encoded> </item> <item><title>By: GFoley83</title><link>http://viralpatel.net/blogs/2008/12/set-maxlength-of-textarea-input-using-jquery-javascript.html/comment-page-1#comment-25606</link> <dc:creator>GFoley83</dc:creator> <pubDate>Fri, 27 Jan 2012 02:13:05 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=162#comment-25606</guid> <description>Updated version for jQuery 1.3+ which also includes text boxes and prevents spaces in IE. [code language=&quot;js&quot;] jQuery.fn.maxlength = function(){ $(&#039;textarea[maxlength], input[maxlength]&#039;).keypress(function(event){ var key = event.which; //all keys including return and space. if(key &gt;= 32 &#124;&#124; key == 13) { var maxLength = $(this).attr(&#039;maxlength&#039;); var length = this.value.length; if(length &gt;= maxLength) { event.preventDefault(); } } }); } [/code]</description> <content:encoded><![CDATA[<p>Updated version for jQuery 1.3+ which also includes text boxes and prevents spaces in IE.</p><pre class="brush: jscript; title: ; notranslate">
jQuery.fn.maxlength = function(){
    $('textarea[maxlength], input[maxlength]').keypress(function(event){
        var key = event.which;
        //all keys including return and space.
        if(key &amp;gt;= 32 || key == 13) {
            var maxLength = $(this).attr('maxlength');
            var length = this.value.length;
            if(length &amp;gt;= maxLength) {
                event.preventDefault();
            }
        }
    });
}
</pre>]]></content:encoded> </item> <item><title>By: Deepak</title><link>http://viralpatel.net/blogs/2008/12/set-maxlength-of-textarea-input-using-jquery-javascript.html/comment-page-1#comment-13481</link> <dc:creator>Deepak</dc:creator> <pubDate>Tue, 30 Nov 2010 06:10:22 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=162#comment-13481</guid> <description>wont work for below text..... :(ああsだどいういえｒをるおいうこくおいううぇｒｙをりｙをれｙをりょしよzｘｃｙぞこいいぇろうぇいｒｙをyを得ｒｗいぇおｒｙをえｒｙをえｒｙをえりょああだづいういあしあいやいしゃいｓｙぢあぢぃあｓぢぃあぢゃいぢゃいうぢゃいうぢゃいうぢゃいうぢゃいづやsぢうあyぢあyぢあぢぃあぢゃいうぢゃいうぢゃいづやいうぢゃいうぢゃいうsぢゃ位末dチャイウェ地亜謝意やいうえやいうえりぃえとぃｒｙうぇいｒｙｗりｗｙりうｗいぇりｗｒｙうぃえうｒｙうぃｒｙうぃえるany suggestion will be appreciated.... thanks in advance...</description> <content:encoded><![CDATA[<p>wont work for below text&#8230;.. <img src='http://viralpatel.net/blogs/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /></p><p>ああsだどいういえｒをるおいうこくおいううぇｒｙをりｙをれｙをりょしよzｘｃｙぞこいいぇろうぇいｒｙをyを得ｒｗいぇおｒｙをえｒｙをえｒｙをえりょああだづいういあしあいやいしゃいｓｙぢあぢぃあｓぢぃあぢゃいぢゃいうぢゃいうぢゃいうぢゃいうぢゃいづやsぢうあyぢあyぢあぢぃあぢゃいうぢゃいうぢゃいづやいうぢゃいうぢゃいうsぢゃ位末dチャイウェ地亜謝意やいうえやいうえりぃえとぃｒｙうぇいｒｙｗりｗｙりうｗいぇりｗｒｙうぃえうｒｙうぃｒｙうぃえる</p><p>any suggestion will be appreciated&#8230;. thanks in advance&#8230;</p> ]]></content:encoded> </item> <item><title>By: Murali</title><link>http://viralpatel.net/blogs/2008/12/set-maxlength-of-textarea-input-using-jquery-javascript.html/comment-page-1#comment-13401</link> <dc:creator>Murali</dc:creator> <pubDate>Thu, 18 Nov 2010 13:29:39 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=162#comment-13401</guid> <description>Please have a look into thishttp://that-matt.com/2010/04/updated-textarea-maxlength-with-jquery-plugin/</description> <content:encoded><![CDATA[<p>Please have a look into this</p><p><a href="http://that-matt.com/2010/04/updated-textarea-maxlength-with-jquery-plugin/" rel="nofollow">http://that-matt.com/2010/04/updated-textarea-maxlength-with-jquery-plugin/</a></p> ]]></content:encoded> </item> <item><title>By: Max</title><link>http://viralpatel.net/blogs/2008/12/set-maxlength-of-textarea-input-using-jquery-javascript.html/comment-page-1#comment-12293</link> <dc:creator>Max</dc:creator> <pubDate>Mon, 15 Mar 2010 16:53:16 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=162#comment-12293</guid> <description>Hi Here&#039;s another way to do it. http://www.problemquestionsolution.com/View/JavaScript/Textarea-maxlength</description> <content:encoded><![CDATA[<p>Hi<br /> Here&#8217;s another way to do it.<br /> <a href="http://www.problemquestionsolution.com/View/JavaScript/Textarea-maxlength" rel="nofollow">http://www.problemquestionsolution.com/View/JavaScript/Textarea-maxlength</a></p> ]]></content:encoded> </item> <item><title>By: Zachary Burt</title><link>http://viralpatel.net/blogs/2008/12/set-maxlength-of-textarea-input-using-jquery-javascript.html/comment-page-1#comment-12202</link> <dc:creator>Zachary Burt</dc:creator> <pubDate>Thu, 25 Feb 2010 23:13:37 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=162#comment-12202</guid> <description>My version, compatible with jQuery 1.3[code language=&quot;js&quot;] $(&quot;textarea[maxlength]&quot;).keypress(function(event){ var key = event.which;//all keys including return. if(key &gt;= 33 &#124;&#124; key == 13) { var maxLength = $(this).attr(&quot;maxlength&quot;); var length = this.value.length; if(length == maxLength) { event.preventDefault(); $(&quot;#error_field&quot;).html(&#039;Maximum length is 120 characters.&#039;); } } }); [/code]</description> <content:encoded><![CDATA[<p>My version, compatible with jQuery 1.3</p><pre class="brush: jscript; title: ; notranslate">
	$(&quot;textarea[maxlength]&quot;).keypress(function(event){
		var key = event.which;

		//all keys including return.
		if(key &amp;gt;= 33 || key == 13) {
			var maxLength = $(this).attr(&quot;maxlength&quot;);
			var length = this.value.length;
			if(length == maxLength) {
				event.preventDefault();
				$(&quot;#error_field&quot;).html('Maximum length is 120 characters.');
			}
		}
	});
</pre>]]></content:encoded> </item> <item><title>By: Viral Patel</title><link>http://viralpatel.net/blogs/2008/12/set-maxlength-of-textarea-input-using-jquery-javascript.html/comment-page-1#comment-12177</link> <dc:creator>Viral Patel</dc:creator> <pubDate>Tue, 23 Feb 2010 10:50:41 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=162#comment-12177</guid> <description>@Gurinder: Ofcourse pasting something will not work as already mentioned above. I will soon modify the code and try to fix this. :)</description> <content:encoded><![CDATA[<p>@Gurinder: Ofcourse pasting something will not work as already mentioned above. I will soon modify the code and try to fix this. <img src='http://viralpatel.net/blogs/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p> ]]></content:encoded> </item> <item><title>By: Gurinder</title><link>http://viralpatel.net/blogs/2008/12/set-maxlength-of-textarea-input-using-jquery-javascript.html/comment-page-1#comment-12157</link> <dc:creator>Gurinder</dc:creator> <pubDate>Mon, 22 Feb 2010 00:20:33 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=162#comment-12157</guid> <description>Try pasting a long text , This plugin  will fail.</description> <content:encoded><![CDATA[<p>Try pasting a long text , This plugin  will fail.</p> ]]></content:encoded> </item> <item><title>By: BenTheTipsyBear</title><link>http://viralpatel.net/blogs/2008/12/set-maxlength-of-textarea-input-using-jquery-javascript.html/comment-page-1#comment-12096</link> <dc:creator>BenTheTipsyBear</dc:creator> <pubDate>Fri, 12 Feb 2010 22:32:41 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=162#comment-12096</guid> <description>Okay - the spaces and backspaces are easy enough to add: Replace: if(key &gt;= 33 &#124;&#124; key == 13) { With: if(key &gt;= 32 &#124;&#124; key == 13 &#124;&#124; key == 8) {Cheers!</description> <content:encoded><![CDATA[<p>Okay &#8211; the spaces and backspaces are easy enough to add:<br /> Replace:<br /> if(key &gt;= 33 || key == 13) {<br /> With:<br /> if(key &gt;= 32 || key == 13 || key == <img src='http://viralpatel.net/blogs/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> {</p><p>Cheers!</p> ]]></content:encoded> </item> <item><title>By: BenTheTipsyBear</title><link>http://viralpatel.net/blogs/2008/12/set-maxlength-of-textarea-input-using-jquery-javascript.html/comment-page-1#comment-12095</link> <dc:creator>BenTheTipsyBear</dc:creator> <pubDate>Fri, 12 Feb 2010 22:22:36 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=162#comment-12095</guid> <description>This would be much more useful revised to recalculate with spaces and backspaces. The cut and paste issue should be rolled in as well... Thanks!</description> <content:encoded><![CDATA[<p>This would be much more useful revised to recalculate with spaces and backspaces.<br /> The cut and paste issue should be rolled in as well&#8230;<br /> Thanks!</p> ]]></content:encoded> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced

Served from: viralpatel.net @ 2012-02-09 10:38:41 -->
