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

Text entry validation in branch logic to terminate respondent with Regex

  • January 29, 2024
  • 4 replies
  • 107 views

Forum|alt.badge.img+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).

Best answer by Shashi

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

 

 

4 replies

Shashi
Level 8 ●●●●●●●●
Forum|alt.badge.img+34
  • Level 8 ●●●●●●●●
  • 654 replies
  • January 29, 2024

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.


Forum|alt.badge.img+1
  • Author
  • Level 1 ●
  • 7 replies
  • January 29, 2024

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

 


Shashi
Level 8 ●●●●●●●●
Forum|alt.badge.img+34
  • Level 8 ●●●●●●●●
  • 654 replies
  • Answer
  • January 29, 2024

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

 

 


Forum|alt.badge.img+1
  • Author
  • Level 1 ●
  • 7 replies
  • January 29, 2024

Thank you @Shashi ! This worked.