!
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.
I am facing the same problem. I need to validate the zip codes of a specific US state against a text entry question of “What is your zip code?”.
Thanks
Use:
Qualtrics.SurveyEngine.addOnPageSubmit(function() {
var zipArray = [ /* list of zip codes here */];
if(zipArray.includes("#"+this.questionId+" .InputText")) { /* zip match, do something */ }
});
Thanks
Thanks
The code is meant as a starting place for you to add to as indicated by the comments, not to work as-is. Post the code you are using.
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.