/ Published in: jQuery

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$(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; } }
URL: http://www.ajaxray.com/blog/2007/11/09/interactive-character-limit-for-textarea-using-jquery/
Comments
