jeudi 18 août 2016

JavaScript : trouble with If else if statement with multiple conditions

I have 4 conditions; first three need to display error priority wise, the 4th one if all first three are false. I can't make it to work. How can I combine first 3 conditions in this statement?

if ((requireK3Action.length) || (requireAction.length) || (InvalidK3Action.length) ){

        if(InvalidK3Action.length){
            alert("Invalid condition 1");       
        }
        e.preventDefault();
        return false;

        if (requireK3Action.length){
            alert("Invalid condition 2");       
        }
        e.preventDefault();
        return false;

        if(requireAction.length){
            alert("Invalid condition 3");       
        }
        e.preventDefault();
        return false;


        // all first 3 conditions satisfy
    } else if(!hasValidbehavior && noAction.length) {
        alert(" checking condition 4 ")
        e.preventDefault();
        return false;
    }

Aucun commentaire:

Enregistrer un commentaire