I have this loop running after a click(), and it does not return false if the return false is placed deeper within the iterator. How can I ensure it returns false; ?
$.each($(".payment"), function(key, value) {
the_date = $(value).children("input:first").val();
if( the_date != "") {
if( the_date.split("/").length != 3) {
return false; // <--- This doesn't work
};
};
};
Here’s another validator that does work
if( $("input#date_awarded").val().split("/")[2] > 2010 ) {
return false; // <-- Totally works
};
In an
.each(), doingreturn falsereturns from the each callback, and halts the loop.Instead you could use a variable to hold the return value, and return that after the loop.