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!

Jim W (Moderator) 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


      Question stats

      • Active
      • Views2008 times
      • Answers1 answer
      • Followers1 follower