Limite de caracteres em textarea


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function textCounter(field, countfield, maxlimit) {
  2. if (field.value.length > maxlimit){
  3. field.value = field.value.substring(0, maxlimit);
  4. } else {
  5. countfield.value = maxlimit - field.value.length
  6. }
  7. }
  8. $('textarea').keydown(function(){
  9. textCounter(this.form.campo9,this.form.remLen,3000);
  10. });
  11. $('textarea').keyup(function(){
  12. textCounter(this.form.campo9,this.form.remLen,3000);
  13. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.