i want to add class text-danger
when i type more than max word in textarea
.
here what i try
var max_chars = 230;
document.getElementById('description').onkeyup = function () {
document.getElementById('count_char').innerHTML = (max_chars - this.value.length) + "/";
};
$('#description').on('textarea', function () {
checkWord();
});
function checkWord(){
var maxword = 230;
var note = document.getElementById("descnote");
if (minword < Number($('#description').val().length)){
note.classList.add("text-danger");
}
}
my form
<textarea class="form-control" name="description" id="description" form="tambah_post" rows="3" required></textarea>
<small id="count_char"></small><small id="descnote">230 Sisa Rekomendasi.</small>