the truth is strange what happens. I'm trying to limit a textarea that takes a description. use the "keypress" event in the browser and everything worked well, but the application is not working. No receipt errors or anything like that, just not working.
var limite = 140;
$scope.resta = 0;
$('#counter').html("Quedan "+limite+" caracteres");
$("#text_view").keyup(function(e, $event){
var box = $(this).val();
var value = (box.length *100) / limite;
$scope.resta = limite - box.length;
if(box.length <= limite || $scope.resta > 0){
$('#counter').html("Quedan "+$scope.resta+" caracteres");
}
else{
$('#counter').html("Quedan "+$scope.resta+" caracteres");
e.preventDefault();
return;
}
});
Also try keyup, this if it works, but in the textarea is still writing and not respesta the limit until the user presses a space.