How do I validate zipcode text entry against a list of approved zipcodes

HE_SurveyHE_Survey Community Member Qubie ✭
edited October 2019 in Best Practices

How do I validate zipcode text entry against a list of approved zipcodes

I want to ask the question "What is your zipcode?" as a text entry question and then based off the entered zipcode either terminate the survey or continue to next question. I have a list of 3000+ zipcodes and the respondent must live in one of the zipcodes in order to continue the survey. I tried using the Authenticator, but that only allows for the zipcode to be entered one time and there might be many respondents that live in one zipcode. Any tips?

Best Answer

  • TomGTomG Raleigh, NC Wizard ✭✭✭✭✭
    Accepted Answer


    Sorry, but you don't want to do what @Igee suggests. Respondents with the same zip code would be overwriting each others responses.

    An Authenticator is not the right solution. The best solution is to use a webservice call that queries an external database to tell you if the person's zip code is in the list of valid zip codes. The webservice would return a variable that tells you if a valid zip code was entered. Then use a branch condition to terminate those that aren't valid. Unfortunately, you need access to a web server and the ability to write a script to do this.

    If you can't manage that, a secondary solution would be to put all 3000 zip codes in a JavaScript array, then search the array for a match and set an embedded variable based on whether a match was found.

    You haven't said what the 3000 zip codes represent, but if they represent a state or group of states you could use the built-in QState_ExportTag_suffix embedded variable and branch based on that (the idea being that it could possibly it to a manageable number that could be used in branch logic). See built-in embedded data for more info.


  • IgeeIgee Community Member Guru ✭✭

    hi @HE_Survey - Within the Authenticator -> Options there is an option mentioning - "Allow authenticating respondents to retake authenticated section" you can select this and have multiple people from the same location take your survey with using the Authenticator, see image attached. Hope this helps.

Sign In to Comment