Date AND Time Validation | XM Community
Solved

Date AND Time Validation

  • 27 November 2023
  • 10 replies
  • 195 views

Userlevel 3
Badge +10

Hello,

 

I need to add a validation to my survey and saw there are ‘Date format’ options under ‘Content type’; however, I’m looking to add date AND time validations to my question.  I’m assuming this is possible by creating a Custom Validation. If so, does anyone have any insight on how I may accomplish this?

Thank you!

icon

Best answer by Deepak 27 November 2023, 21:52

View original

10 replies

Userlevel 7
Badge +36

@valdy34

Hi, if you are looking for date and time validation in single answer text entry can you let me know what date and time format are you looking for?

You can include Regex type custom validation based on it.

Userlevel 3
Badge +10

@valdy34

Hi, if you are looking for date and time validation in single answer text entry can you let me know what date and time format are you looking for?

You can include Regex type custom validation based on it.

mm/dd/yyyy, HH:MM XM

Thank you!

Userlevel 7
Badge +36

@valdy34

If you want in mm/dd/yyyy, HH:MM XM (AM PM) use below include it in Regex Custom Validation.

^(0[1-9]|1[0-2])\/(0[1-9]|[12][0-9]|3[01])\/\d{4}, (0[1-9]|1[0-2]):([0-5][0-9]) [APap][Mm]$

Hope it helps!

Userlevel 3
Badge +10

@valdy34

If you want in mm/dd/yyyy, HH:MM XM (AM PM) use below include it in Regex Custom Validation.

^(0[1-9]|1[0-2])\/(0[1-9]|[12][0-9]|3[01])\/\d{4}, (0[1-9]|1[0-2]):([0-5][0-9]) [APap][Mm]$

Hope it helps!

This did the trick! Thank you so much!

Badge +5

Hi Deepak,

Good day! Would you have a variation for time validation in 24-hr format? (e.g. 17:59)? Thanks in advance!

 

Best regards,

Philip 

 

Userlevel 7
Badge +36

@philipangwk 

Try this

^(?:[01]\d|2[0-3]):[0-5]\d$
 

Badge +5

Hi Deepak,

That was quick! Thank you so much!

A silly question here: Where do I add the Regex Custom Validation you very kindly suggested? Is it under JavaScript?

Thanks again!

Userlevel 7
Badge +36

@philipangwk 

Check this link

https://www.qualtrics.com/support/survey-platform/survey-module/editing-questions/validation/#CustomValidation

Badge +5

Hi Deepak,

Thanks for pointing me to the right place! I found where to add the regex validation now. What you suggested worked like a charm. Wonderful! Thanks again!

 

 

Userlevel 3
Badge +10

Deepak is the man!

Leave a Reply