How to add MM/YYYY validation that works with display logic | XM Community
Skip to main content
Question

How to add MM/YYYY validation that works with display logic


Forum|alt.badge.img+1

I’m trying to ask a text entry question that requires the respondent to answer MM/YYYY, and would like to set up subsequent logic branching that only shows when the respondent provides a date before a specific month and year. For example, I want only respondents who endorsed doing an activity before 03/2020 to see a follow up question, and not respondents who endorsed doing that activity at a date after 03/2020.

Thank you!

3 replies

chackbusch
QPN Level 5 ●●●●●
Forum|alt.badge.img+22
  • QPN Level 5 ●●●●●
  • 414 replies
  • August 30, 2024

@eliasg13 Maybe you can try this regex:

^(0[1-2]/2020|0[1-9]/\d{3}|1[0-2]/\d{3})$

`0[1-2]/2020`: Matches `01/2020` or `02/2020`

`0[1-9]/\d{3}`: Matches months `01` to `09` for any year with three digits or more (e.g., 0001 to 9999)

`1[0-2]/\d{3}`: Matches months `10` to `12` for any year with three digits or more

And | as or operator…

Best

Christian


chackbusch
QPN Level 5 ●●●●●
Forum|alt.badge.img+22
  • QPN Level 5 ●●●●●
  • 414 replies
  • August 30, 2024

@eliasg13 Alternatively, you could store the MM/YYYY answer value as embedded data and implement some JavaScript to hide the question (and press the next button if necessary) if your logic applies…


Forum|alt.badge.img+1
  • Author
  • Level 1 ●
  • 8 replies
  • August 30, 2024

@chackbusch Thank you for the suggestions! I don’t know how to code Java, so how would this look as a copy paste into Qualtric’s JavaScript box?


Leave a Reply