I have a simple form I'm making client side validation for. To validate, none of the fields should be left blank. This is how I go at it:
function validateForm() {
$('.form-field').each(function() {
if ( $(this).val() === '' ) {
return false
}
else {
return true;
}
});
}
For some reason, my function always returns false, even though all fields are filled.
See Question&Answers more detail:os