jQuery/HTML- Count characters in textarea

Topic: 1.Character Counting Remaining on textarea using jQuery.

Topic: 2. jQuery- Count characters in textarea

Topic: 3. How can I count characters in textarea on onkeyup() event using jQuery?

Solution:

We can find above topics solutions in below code.

STEP 1: Include jQuery

 

STEP 2: Script

 
function countChar(val) {
        var len = val.value.length;
        if (len >= 500) {
          val.value = val.value.substring(0, 500);
        } else {
          $('#charNum').text(500 - len);
        }
};

STEP 3: HTML

 
 
Remaining limit:500 characters

No comments:

Post a Comment