I have a chat system, and the send button should not be enabled while the user does not type a letter.
In the example below the button is enabled when the user types something, but if he type only spaces the button is displayed.
$('#msg').on('keyup',function() {
var textarea_value = $("#msg").val();
if(textarea_value != '') {
$('.button-enviar').attr('disabled' , false);
$('.button-enviar').removeClass('disabled');
}else{
$('.button-enviar').attr('disabled' , true);
$('.button-enviar').addClass('disabled');
}
});
How to check if the variable textarea_value contains only spaces? So do not enable the button.