1. Here's the script that goes in the <head></head> tags:
<SCRIPT LANGUAGE="JavaScript">
<!--Hide from old browsers
function checkState(form){
var selectIndex;
var CountryValue;
var fullCountry;
for(i = 0; i < form.elements.length -1; i++){
if(form.elements[i].name == "22_destCountry"){
selectIndex = form.elements[i].selectedIndex;
CountryValue = form.elements[i].options[selectIndex].value;
fullCountry = form.elements[i].options[selectIndex].text;
}
if(form.elements[i].name == "12-M-STATE"){
var stateValue = form.elements[i].value;
if((CountryValue == "US")&&(stateValue == "")){
alert("\nSince you selected " + fullCountry + " for your country, you" +
"\nmust enter your state abbreviation before going to checkout.\n");
form.elements[i].focus();
return false;
}
}
}
return true;
}
// End hiding -->
</SCRIPT>
2. Here's the event trigger tag:
<FORM ACTION="%%secure_script_url%%" METHOD="POST" TARGET="_top" onSubmit="return checkState(this);">