Thread: zip code check
View Single Post
  #2  
Old 05-01-2006, 08:40 AM
 
zaa zaa is offline
 

X-Cart team
  
Join Date: Apr 2004
Location: Ulyanovsk, Russia
Posts: 125
 

Default

Try this one:

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!="" && !(zip.value.length >=5 || zip.value.length <=9)) alert_str = us_zip_code; } else if (cnt.value=="CA") { if (zip.value!="" && !(zip.value.length >=5 || zip.value.length <=9)) 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>
Reply With Quote