Text entry validation in branch logic to terminate respondent with Regex | XM Community
Solved

Text entry validation in branch logic to terminate respondent with Regex

  • 29 January 2024
  • 4 replies
  • 49 views

Badge +1

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).

icon

Best answer by Shashi 29 January 2024, 20:50

View original

4 replies

Userlevel 6
Badge +27

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.

Badge +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

 

Userlevel 6
Badge +27

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

 

 

Badge +1

Thank you @Shashi ! This worked.

Leave a Reply