Zen Cart Logo
Forums / General Questions / Can I add Zip Code Validation (ie: check is it a real zip code?) to a custom form?

Can I add Zip Code Validation (ie: check is it a real zip code?) to a custom form?

Views: 1,081

Results 1 to 3 of 3
21 Oct 2012, 1:04 AM
#1
sparrowce avatar

sparrowce

Zen Follower

Join Date:
Feb 2011
Posts:
207
Plugin Contributions:
0

Can I add Zip Code Validation (ie: check is it a real zip code?) to a custom form?

Have not yet upgraded to 1.5 but have a question on addresses/zip code validation. When I test and change addresses in my store account (logging in as a customer), I can put a bad zip code in the zip field and it does not tell me it's not valid. For the storefront, am using EZ Pages and links to html pages with 'buy' buttons linking to store ID and on the website also have a 'free offer' html form that is processed by php file. The free offer form is not part of the ZenCart, but as we move towards being able to upgrade to the latest ZenCart, am hoping there might be a way to move the free offer form to a ZenCart form and that there will be a way to validate the Zip Code is real for USA. Am looking for more than just ensuring for USA it's numerical and/or 5-4 format, as that's already in place, but am not finding a way to ensure if they enter a phoney zip code that the form won't process. Can this be handled within ZenCart, and if so, where would I begin? The upgrade is on the schedule, though I am concerned because of so many customizations so have been slow to begin. Anyway, please advise if more info is needed or further explanation, thank you for any help.

21 Oct 2012, 10:31 AM
#2
david_allen avatar

david_allen

Zen Follower

Join Date:
Feb 2008
Location:
Amersham, Buckinghamshire, United Kingdom
Posts:
141
Plugin Contributions:
1

Re: Can I add Zip Code Validation (ie: check is it a real zip code?) to a custom form?

I think this can be handled within Zen relatively easily. In the latest 1.5.1 there has been a notifier hook added to the create account process which is intended for a reCAPATCHA check. My Google reCAPATCHA mod makes use of it to try to stop spam accounts. This could easily be modified to instead check the zip code for correctness instead.
Not sure about the edit account, but at least they will have created the account with a correct Zip.

21 Oct 2012, 8:56 PM
#3
sparrowce avatar

sparrowce

Zen Follower

Join Date:
Feb 2011
Posts:
207
Plugin Contributions:
0

Re: Can I add Zip Code Validation (ie: check is it a real zip code?) to a custom form?

Thank you very much. I will check that out and it looks like I need to go ahead and do the upgrade so your mod can be utilized. This will be more for a form that does not go through the store, it's a free offer but maybe I am handling it wrong and should find a way to run it through ZenCart instead. It sounds like I need to first backup and start the upgrade process and then come back to address this form issue.