View Single Post
  #33  
Old 11-17-2004, 11:04 AM
  kangus's Avatar 
kangus kangus is offline
 

Senior Member
  
Join Date: Feb 2003
Posts: 160
 

Default Short form of ZIP check -

Replace the function in check_zipcode_js.tpl:

function check_zip_code_field(cnt, zip){
var valid = "0123456789-";
var hyphencount = 0;
if (cnt.options[cnt.selectedIndex].value=="US") {
if (zip.value.length!=5 && zip.value.length!=10 && zip.value!="") {
alert("Please enter your 5 digit or 5 digit+4 zip code formated like '12345-6789'.");
zip.focus();
return false;
}
for (var i=0; i < zip.value.length; i++) {
temp = "" + zip.value.substring(i, i+1);
if (temp == "-") hyphencount++;
if (valid.indexOf(temp) == "-1") {
alert("Invalid characters in your zip code. Please try again.");
zip.focus();
return false;
}
if ((hyphencount > 1) || ((zip.value.length==10) && ""+zip.value.charAt(5)!="-")) {
alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'. Please try again.");
zip.focus();
return false;
}
}
return true;
}else if (cnt.value=="CA") {
if (zip.value.length!=6 && zip.value.length!=7 && zip.value!="") {
alert("Ensure that you have 6 or 7 characters in your postal code")
zip.focus()
return false
}
}
return true
}
__________________
X-cart 3.3.1 ~ 4.0.18 4.1.1
PHP4/5 MySQL 4.1.10a/5.1
CENTOS 4.1 / SuSE 9.3 / MS Server
Authorize.Net Partner
Reply With Quote