Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

zip code check

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #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
  #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
  #3  
Old 05-20-2006, 01:52 AM
 
maildodge maildodge is offline
 

Senior Member
  
Join Date: Feb 2005
Posts: 109
 

Default

Thanks, I was looking for something like this. Worked a treat
__________________
http://www.stand-out.net

X-Cart 4.0.16
Reply With Quote
  #4  
Old 05-20-2006, 03:29 AM
 
cotc2001 cotc2001 is offline
 

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

Default

Didn't work for me im afraid, it allowed users to use even just 1 digit for the zip code.
__________________
x-cart 4.0.5 (live and heavily modded)
Server: freebsd
Reply With Quote
  #5  
Old 05-21-2006, 01:00 PM
  Vacman's Avatar 
Vacman Vacman is offline
 

X-Adept
  
Join Date: Sep 2005
Location: Torrance, CA
Posts: 792
 

Default

I would like to take this to even a next step - I just encountered this problem today - not for the first time.

Sometimes my customer get a little over-zealous in filling out their order forms and by way of example, type in Marietta, CA with a zip code of 30062 - well it turns out that the state should have been Georgia, not California. My old e-Commerce software had a checker for this issue - would be nice for XCart to do this...
__________________
Carl Tice

X-Cart 4.6.6
X-Payments 3.0
ReBOOT 3.4.1

PHP 5.6.30
MySQL 5.6.35
Linux 2.6.32-042stab120.18
ionCube PHP Loader v4.7.3
Perl 5.10.1
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 11:09 PM.

   

 
X-Cart forums © 2001-2020