Text entry validation in branch logic to terminate respondent with Regex | XM Community
Skip to main content

Hello! I’ve tried the following regex to test for text entry answers (string) that contain 6 to 10 characters: ^.{6,10}$

While this works for validating the question, it does not work for terminating respondents whose answers don’t fall within these parameters.

(I’m aware that I could change the data type from string to number but I am new to coding so not sure how to do so in javascript -- a kind person shared code for automatically adding commas to currency numbers but this makes the value a string so I’m trying to figure out how to validate based on number of characters).

Try this:

Before branch logic set an embedded data ‘regexPassed’ and value as 0.

In branch logic insead of end of survey, updated ‘regexPassed’ embedded data to 1.

Add another brnach logic after above branch logic to check if ‘regexPassed’ equal to 0 then end of survey.


thanks for your response @Shashi 

Where do I add the regex formula though?

I also don’t think I understood your instructions because what I have below doesn’t make much sense to me

 


Between embedded data regex set to 0 and 1 just add the branch logic you have in your question i.e. regex formula condition and in this branch logic set ‘regexPassed’ to 1.

thanks for your response @Shashi 

Where do I add the regex formula though?

I also don’t think I understood your instructions because what I have below doesn’t make much sense to me

 

 


Thank you @Shashi ! This worked.


Leave a Reply