// Check for ZipCodes in US territories. If so, alert user that orders may only go to Continental US /*APO/FPO 09,340,962,963,964,965,966 Pacific Islands (HI, PW, FM, MH, MP, GU, AS) 967,968,969 Puerto Rico / Virgin Islands (PR, VI) 006,007,008,009 */ function checkZip(zip) { delivery = document.cartform.deliver_to; if (!checkDest(delivery)) { zip.value = ""; return false; } var bad_codes = new Array("^09","^340","^962","^963","^964","^965","^966","^967","^969","^006","^007","^008","^009"); var checker = new RegExp(); var code; for (code in bad_codes) { checker.compile(bad_codes[code]); if (checker.test(zip.value)) { alert("Sorry, we only ship to the Continental US."); zip.value = ""; return false; } } // Zip code is good if we get here return true; } function checkCheckoutZip(zip) { var bad_codes = new Array("^09","^340","^962","^963","^964","^965","^966","^967","^969","^006","^007","^008","^009"); var checker = new RegExp(); var code; for (code in bad_codes) { checker.compile(bad_codes[code]); if (checker.test(zip.value)) { alert("Sorry, we only ship to the Continental US."); zip.value = ""; return false; } } // Zip code is good if we get here return true; } function checkCountry(country) { if (country.value == 'US' || country.value == 'CA') { return true; } else { alert ('Sorry, we only ship to the US or Canada.'); country.value = ''; return false; } } function checkEnter(e){ //e is event object passed from function invocation var characterCode; //literal character code will be stored in this variable if(e && e.which){ //if which property of event object is supported (NN4) characterCode = e.which; //character code is contained in NN4's which property } else{ if (event) e = event; characterCode = e.keyCode; //character code is contained in IE's keyCode property } if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key) //var answer = confirm("Do you want to continue to Check Out?"); return false; if (answer) { returnObjById("continue").submit(); //submit the form return false; } else return false; } else{ return true; } } function checkDest(delivery) { if (delivery[0].checked == true || delivery[1].checked == true) return true; else { alert("Please select where this order will be shipped to."); return false; } } function returnObjById( id ) { if (document.getElementById) var returnVar = document.getElementById(id); else if (document.all) var returnVar = document.all[id]; else if (document.layers) var returnVar = document.layers[id]; return returnVar; }