/ Published in: jQuery
Textauszählen mit jQuery einfach gemacht ;)
Expand |
Embed | Plain Text
$('#message').keyup(function(){ limitChars('message', 160, 'charlimitinfo'); }); // The Function 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) +''); return true; } }
You need to login to post a comment.
