When I run this code, my if AND else statements run. I'm assuming it has something to do with my for loop, but am hitting a wall.
$('#patientForm').submit(function(e) {
var ref = $(this).find("[required]");
$(ref).forEach(function() {
console.log(ref.length);
if ($(this).val() === '') {
alert("Required field should not be blank.");
$(this).focus();
e.preventDefault();
// return false;
} else {
console.log("else statement is running");
Aucun commentaire:
Enregistrer un commentaire