Validate text box entry for zip code


I have a survey qualifier question of a text box that asks a user to enter their zip code.  Only zip codes within our metro area are allowed to continue, all others will disqualify.  I have a list of around 330 zip codes to match against.  I know i can set up Skip/Disqualify logic for this, but do not want to have to setup all 330 conditions!

I have been looking for alternatives ways to approach this.  First, is there a non-scripting way to achieve this (match against a list)?  If not, I have been playing with some scripting with no luck (still a rookie in custom scripting).  My first approach has been to have a Hidden Value with the list of zip codes, but that doesn’t seem to work.  The script is below:

%%zip_enter = sgapiGetValue(10); //Zip Code text box
%%zip_list = sgapiGetValue (116); //hidden value holding zip codes

if (%%zip_enter == %%zip_list) {
if (%%zip_enter !== %%zip_list) {

My next thought is, is there a way in the script to have the list of zip codes to match?  Not sure how I would approach this.  \

Any help would be greatly appreciated on this!

Damien answered

    I would want to exhaust all possibilities of using the Skip/Disqualify logic before trying custom scripting.  It should not necessary to test against 330  zip codes.  If you are dealing with codes within a specific area, don’t they all fall into a certain range that you can define with Greater Than / Less Than statements?  And you can create multiple Skip/Disqualify conditions to cover all of the exceptions.


    Jim W (Moderator) answered

      I have the same problem but with a much larger postcode list that is in separate blocks i.e. need to exclude anyone that doesn’t live in 2000-2190; 3000-3230; 4000 – 4050; 8000-8115.

      Any other suggestions? Surely someone has come up with a custom script to solve this problem by now as it’s a pretty standard approach in market research.

      Damien answered


        Question stats

        • Active
        • Views2828 times
        • Answers2 answers
        • Followers1 follower