mercredi 4 mars 2015

Jquery Breaking out of IF Statement - EXIT;

I've got a statement like this :



$("#submit").click(function(e) {
if (!confirm('Continue ?')) { return false; }


if (!$("#all").is(':checked')) {
$(".A").each(function() {
if($(this).val() == '0') { alert ('A - This Value Must Be Set'); return false; }
});

$(".B").each(function() {
if($(this).val() == '0') { alert ('B - This Value Must Also Be Set'); return false; }
});

$(".C").each(function() {
if ($(this).val().length < 1) { alert ('C - This Must Be Set'); return false; }
if (!$.isNumeric(this.value)) { alert ('C - Only Numeric Values'); return false; }
});
}
});


If any class 'A' has the value of 0 then I get an alert:


A - This Value Must Be Set


This is fine, but I then get checked by the class 'B' & class 'C' check. What I want it to do is stop all extra checking when either an A, B & C Alert are sent.


Can that be done ?


Thanks


Aucun commentaire:

Enregistrer un commentaire