How to validate multiple functions with one IF statement - Javascript, jQuery -
How to validate multiple functions with one IF statement - Javascript, jQuery -
i want validate multiple functions, , each 1 returning false, animations.
here's code:
function validarchido(){ var dedo = $('#dedo_pick'); if(dedo.children().size() < 2){ dedo.animate({'background-color' : 'red'},200); dedo.animate({'background-color' : '#eee'},200); homecoming 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); homecoming false; } else{return true;} } $('#form').submit(function(){ if( validarchido() && validarex() ) {return true } else {return false; } });
when send form, see first function doing color animation, because form validation if statement doesn't evaluate next function because first resulted in false here if( validarchido() && validarex() )
is there way evaluate functions , see animation in each 1 , send form if true?
instead of returning false or true similar following:
function validarchido() { var dedo = $('#dedo_pick'); if(dedo.children().size() < 2){ dedo.animate({'background-color' : 'red'},200); dedo.animate({'background-color' : '#eee'},200); homecoming "error"; } else{return "";} } function validarex(){ var valex = $('#rate1'); if(valex.children().size() < 2){ valex.animate({'background-color' : 'red'},200); valex.animate({'background-color' : '#eee'},200); homecoming "error"; } else{return "";} } $('#form').submit(function(){ var check = validarchido(); check += validarex(); if( check == "" ) {return true } else {return false; } });
javascript jquery function if-statement
Comments
Post a Comment