, , , ,

Always use input event for validation so as whenever key press or up but does not change the text change the content in textarea like cltr / Alt / up / down keys , mouse roller paste in linux ,  that time events like keyup , press will not work

so use input change event every time for input field validation.

also make sure server side validation working

<textarea class=”col-md-12 form-control” rows=”5″ id=”msg” name=”msg”></textarea>

var allowedCount=110;
var textCount=$(“#msg”).val().length;;

$(“#msg”).on(‘keyup change input’,function(){
textCount = $(“#msg”).val().length;
if(textCount <= allowedCount){
}else if(textCount > allowedCount){
$(“#msg”).val($(“#msg”).val().substr(0, allowedCount));
return false;