textarea monitors the number of characters

<textarea onpaste="return false;" name="text-content" class="text-content" placeholder="写下您的祈福" rows="6" onkeyup="count_words(this)"> </textarea>
        <div><span id="count-words">0</span>/60 <span>限60字</span></div>
var _tempwords = "";
    function count_words(){
        var count = 60 - $(".text-content").val().trim().length;
        if(count>=0){
            $("#count-words").html(count);
            _tempwords = $(".text-content").val();
        }else{
            $(".text-content").val(_tempwords);
            alert("长度不能超过60个字符");
        }
    }

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325521230&siteId=291194637