Return to Snippet

Revision: 45749
at May 6, 2011 22:32 by erraja_07


Initial Code
$(document).ready(function(){ 
	$(function(){
		$('#bid_desc-plaintext').keyup(function(){
		limitChars('bid_desc-plaintext', 4000, 'typed_txt_count');
		})
	});
});

	function limitChars(textid, limit, infodiv)
	{
		var text = $('#'+textid).val(); 
		var textlength = text.length;
		if(textlength > limit)
		{
			$('#' + infodiv).html('You cannot write more then '+limit+' characters!');
			$('#'+textid).val(text.substr(0,limit));
			return false;
		}
		else
		{
			$('#' + infodiv).html((limit - textlength) +' characters left.');
			return true;
		}
	}

Initial URL
http://www.ajaxray.com/blog/2007/11/09/interactive-character-limit-for-textarea-using-jquery/

Initial Description


Initial Title
Jquery Limit Text in Textarea

Initial Tags
text

Initial Language
jQuery