I make a jquery validation, problem is here that this part from code first(first click on button) check selectbox and second(second click on button) fields. how can it fix as that check all together with one click on button?
Exampel(see full code): http://jsfiddle.net/JfPaN/
$('.submit').submit(function () {
if (required_selectbox() == false || required_valid() == false) {
return false;
}
});
Your problem is caused by Short-Circuit Evaluation on this line expression :
Javascript will not execute
required_valid()ifrequired_selectbox()returns false, since it already knows the result of the boolean expression as soon as the left side is true.Here is one solution to your problem: