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

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!

@eliasg13 Maybe you can try this regex:

^(001-2]/2020|001-9]/\d{3}|110-2]/\d{3})$

`001-2]/2020`: Matches `01/2020` or `02/2020`

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

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

And | as or operator…

Best

Christian


@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…


@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