Logic in an IF statement

From stackoverflow

by Egli

HTML

Testing some conditions

JavaScript

//Set up your variables to test here
var Type = "A";
var Field1 = "";
var Field2 = "";

//Test conditions
if(Type == "A" && (Field1 == "" || Field2 == ""))
{
    alert("In: Condition 1");
}
else if(Type == "B" && (Field1 == "" || Field2 == ""))
{
    alert("In: Condition 2");
}
else
{
    alert("script for approval!");
}