How to add Maxlength for textarea #231

Open
thuatnha opened this Issue Mar 22, 2013 · 2 comments

Comments

Projects
None yet
2 participants

Plz! I can't Add Maxlength to Textarea. Plz help me.

thuatnha commented Apr 1, 2013

Plz Help me.

ykbks commented May 25, 2016 edited

This worked for me, should for you:

$('#content').wysihtml5({
          events: {
            load: function() {
              var editor = this;
              $(editor.currentView.doc.body).on("keydown",function(event) {
                var l = event.currentTarget.innerText.length;
                if(l >= 1000) {
                  $('#count').html('<span class="text-danger">Total characters exceed 1000. Extra characters will not be saved.</span>');
                } else {
                  var left = 1000 - l;
                  $('#count').html('<span class="text-info">'+ left + ' characters left ' +'</span>');
                }
              }); 
            }
          }
       });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment