2
I am manually imposing character limit on my textareas with this code:
<textarea onKeyDown="limitText(this.form.message,this.form.countdown,240);"
onKeyUp="limitText(this.form.message,this.form.countdown,240);"></textarea>
But I came to the conclusion that it soils and occupies space. I would like to turn to jQuery to apply this function limitText(this.form.message,this.form.countdown,240);
in all textareas existing on my website.
the function limitText
that’s the one
function limitText(limitField, limitCount, limitNum) {
if (limitField.value.length > limitNum) {
limitField.value = limitField.value.substring(0, limitNum);
} else {
$("#countdown").html(limitField.value.length);
}
}