Hello
@sanm ,
Please follow the below Steps:
Step1: Create an embedded data(zipCode) in survey flow before the zipcode question
Step2: Paste the below code in the js(onReady) of the text entry zipcode question
jQuery("#"+this.questionId+" .InputText").on('keyup',function(){
Qualtrics.SurveyEngine.setEmbeddedData( 'zipCode', jQuery(this).val().toUpperCase());
});
Thanks a lot,
@Shashi ! This was perfect! One last question: Ideally, I would like to remove any numerics from the zipcode response (e.g. "SW9" --> "SW", perhaps with `zipCode.replaceAll("[^A-Z]", "");`), group responses into regions (e.g. by using an if-else command). For instance:
`if(response === "SW"){
var region = 1;
} else {
var region = 0;
}`.
And then save the region variable as embedded data (i.e. not the actual zipcode but the region in which this zipcode is located).
Is there an elegant way to do that in Javascript? Many thanks again for the quick help!
>
@sanm said:
> Thanks a lot,
@Shashi ! This was perfect! One last question: Ideally, I would like to remove any numerics from the zipcode response (e.g. "SW9" --> "SW", perhaps with `zipCode.replaceAll("[^A-Z]", "");`), group responses into regions (e.g. by using an if-else command). For instance:
> `if(response === "SW"){
> var region = 1;
> } else {
> var region = 0;
> }`.
> And then save the region variable as embedded data (i.e. not the actual zipcode but the region in which this zipcode is located).
> Is there an elegant way to do that in Javascript? Many thanks again for the quick help!
Here is the updated code:
jQuery("#"+this.questionId+" .InputText").on('keyup',function(){
Qualtrics.SurveyEngine.setEmbeddedData( 'zipCode', jQuery(this).val().replace(/\\d+/g, '').toUpperCase());
});
Fantastic, thanks a lot again
@Shashi !