lundi 20 février 2017

if statement checking for multiple boolean conditions

I have a if statement that must call function checkEmpty() for every conditions.

function checkFormFilled(evt){
    if(checkEmpty('..', '....') && //condition 1
       checkEmpty('..', '....') && //condition 2
       checkEmpty('..', '....') && //condition 3
       checkEmpty('..', '....')){ //condition 4
       evt.preventDefault();
    }
}

The problem is when the condition 1 is false(any preceding condition is false), skips to the evt.preventDefault() line, doesn't get call other following checkEmpty() functions.

I want to call evt.preventDefault() when all conditions return true.

Is there other way around to make this work?

Aucun commentaire:

Enregistrer un commentaire