I have mentioned my code below, i have a problem with return flase; inside a javascript each function
$(".current_patient_medicine").each(function (i) {
var id = this.id;
var value = $("#" + id).val();
if (value.trim() == "") {
check = false;
alert("Medicine Name cannot left Blank.");
return false;
} else {
check = true;
}
});
$(".current_patient_medicine_days").each(function (i) {
var id = this.id;
var value = $("#" + id).val();
if (value.trim() == "") {
check = false;
alert("Days Field cannot left Blank.");
return false;
} else {
check = true;
}
});
here the first condition alert "Medicine Name cannot left blank" showing well but after that the second alert also showing
breakinstead ofreturn falseif you don't want to make other loops.fororwhile..eachin jQuery is a higher-order function;breakis an illegal statement in this context: cl.ly/image/0M3C1o0P280T/…