I am trying to use JQuery to check whether all inputs in a form have been filled. The viewer clicks a button and if the inputs have been filled, cool stuff happens. But if one of the fields hasn't been filled the viewer needs to get a custom warning message. I think I've almost got it but I need some help.
$(function() {
$("#btn_click").click(function() {
if( $("input").val() == 0 ) {
$("form").append('<span class=".warning">You didn\'t fill out all the fields!</span>');
}
else {
//Some cool stuff happens
}
});
});
When I don't fill in any of the inputs, I get the expected behavior with the warning. That's good. However, the "cool stuff" runs if I fill in the first input and leave all the others blank. That's bad. I want the warning to show if any of the inputs are left blank. How can I make JQuery test all of the inputs?