By Federal law, I need to deny shipping to certain states. I have tested this snippet of code in the "CheckIt function" box of the Commerce Setup>Order System>Checkout page.
- Code: Select all
if (document.billing.ShipState != "AL")
{
alert("Sorry, we cannot legally ship to this state.");
return(false);
}
It works perfectly, but it only blocks one state - Alabama. I have 11 states I need to block. I have tried variations of this code to block all states, but it either seems to block all states or none at all.
Here's one of the variations I used. Don't laugh.
- Code: Select all
if (document.billing.ShipState != "AL", "AR", "KS", "ME", "MD", "MA", "MS", NJ", "OK", "PA", "UT") {
alert("Sorry, we cannot legally ship to this state.");
return(false);
}
How can the first (working) code example be altered to allow for blocking all 11 states?
Thanks for looking. I hope someone has a simple solution.
.