How can I check in jQuery if an input is empty ?
I tried:
$('#location').keydown(function(event) {
if($("#location").val().length == 0 ) { $("#finalSearch").attr('disabled', 'true'); }
if($("#location").val().length != 0 ) { $("#finalSearch").removeAttr('disabled'); }
});
But, I want the alert pop even if there's nothing in my field.
What I want to do:
There's nothing: error message.
There's one letter: no error message.
I remove this letter: error message.
If the field is populate but another function: no error message.
Thanks for help.