I want to validate multiple functions, and for each one returning false, do some animations.
Here's the code:
function validarChido(){
var dedo = $('#dedo_pick');
if(dedo.children().size() < 2){
dedo.animate({'background-color' : 'red'},200);
dedo.animate({'background-color' : '#EEE'},200);
return false;
}
else{return true;}
}
function validarEx(){
var valEx = $('#rate1');
if(valEx.children().size() < 2){
valEx.animate({'background-color' : 'red'},200);
valEx.animate({'background-color' : '#EEE'},200);
return false;
}
else{return true;}
}
$('#form').submit(function(){
if( validarChido() && validarEx() )
{return true }
else
{return false; }
});
When I send the form, I only see the first function doing the color animation, obviously because the form validation IF statement doesn't evaluate the next function because the first resulted in false here if( validarChido() && validarEx() )
Is there a way to evaluate all the functions and see the animation in each one and then send the form if everything is true?