onMatch JS Function for list of countries | Community
Skip to main content
New Participant
March 26, 2024
Solved

onMatch JS Function for list of countries

  • March 26, 2024
  • 2 replies
  • 2703 views

We worked with a third party for form shortening and now we're at a stage where we need to modify their existing code they setup for us to include an onMatch function for a list of countries, where as if country is a match for any of the ones in our list, the form should expand regardless. They provided us with one country example, but we need to expand it to include others. Does anyone know how we can modify this part of the code so we can include more than just Italy?

 

if (!window._zi_fc) {window._zi_fc = {}} window._zi_fc.onMatch = (data) => { if (data.country == 'Italy') { console.log('User located in Italy!');

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Jo_Pitts1

@lizng2 ,

try something like this:

if (!window._zi_fc) {window._zi_fc = {}} window._zi_fc.onMatch = (data) => { const fullFormCountries = ["Italy", "Germany", "France"] if (fullFormCountries.includes(data.country)) { console.log('User located in a full form country');

 

Regards

Jo

2 replies

SanfordWhiteman
New Participant
March 26, 2024

(Parenthetically, one wonders why the 3rd party wouldn’t give you a little more help on this, if they developed the code recently!)

Jo_Pitts1
Community Manager
March 26, 2024

@sanfordwhiteman, quite.

 

I was feeling generous rather than contentious (I know.. strange), so I just gave the answer rather than pushing back. 🙂

Jo_Pitts1
Jo_Pitts1Accepted solution
Community Manager
March 26, 2024

@lizng2 ,

try something like this:

if (!window._zi_fc) {window._zi_fc = {}} window._zi_fc.onMatch = (data) => { const fullFormCountries = ["Italy", "Germany", "France"] if (fullFormCountries.includes(data.country)) { console.log('User located in a full form country');

 

Regards

Jo