Saturday, 7 September 2013

jQuery return false not stopping query from running

jQuery return false not stopping query from running

I have the following code:
else if($page == 'two'){
$('[name^=q1\\[\\]] option:selected').each(function() {
if ($(this).val() < 1) {
$('#rq1').addClass('hovered_error');
$('#mandall').css("background-color","#901F39");
$('#mandall').css("color","#FFF");
return false;
}
});
}
What should happen is if the .val is less than 1 - it should add the
class, change the css of the ID #mandall and then stop the query.
What is actually happening is that it adds the class and changes the css
of #mandall and then keeps going to submit a form - when it shouldn't -
what am I missing?

No comments:

Post a Comment