Thread: zip code check
View Single Post
  #1  
Old 05-01-2006, 07:13 AM
 
cotc2001 cotc2001 is offline
 

X-Man
  
Join Date: Feb 2003
Location: Shrewsbury, UK
Posts: 2,351
 

Default zip code check

Hi,
Im looking at check_zipcode_js.tpl and havent got a clue how to do this.

What I need is to change the default 5 digit code check to a between 5 and 9 digit check (no more 9 digits)

this is the code below

Code:
{* $Id: check_zipcode_js.tpl,v 1.2.2.2 2004/09/15 12:01:47 max Exp $ *} <SCRIPT type="text/javascript" language="JavaScript 1.2"> var us_zip_code = '{$lng.txt_error_us_zip_code|replace:"'":"\'"}'; var ca_zip_code = '{$lng.txt_error_ca_zip_code|replace:"'":"\'"}'; {literal} function check_zip_code_field(cnt, zip){ var alert_str; if(!cnt || !zip) return true; alert_str = ''; if (cnt.options[cnt.selectedIndex].value=="US") { if (zip.value.length!=5 && zip.value!="") alert_str = us_zip_code; } else if (cnt.value=="CA") { if (zip.value.length!=6 && zip.value.length!=7 && zip.value!="") alert_str = ca_zip_code; } if(alert_str.length > 0) { alert(alert_str); zip.focus(); return false; } else return true } function check_zip_code(){ return check_zip_code_field(document.forms["registerform"].b_country, document.forms["registerform"].b_zipcode) && check_zip_code_field(document.forms["registerform"].s_country, document.forms["registerform"].s_zipcode); } {/literal} </SCRIPT>

I don't want to remove the check as is suggested in other posts, just extend it so that US and Canadian have to be between 5 - 9 digits.

Any ideas?
__________________
x-cart 4.0.5 (live and heavily modded)
Server: freebsd
Reply With Quote