Date AND Time Validation | XM Community
Skip to main content
Solved

Date AND Time Validation


valdy34
Level 2 ●●
Forum|alt.badge.img+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!

Best answer by Deepak

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

View original

10 replies

Deepak
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+44
  • 1549 replies
  • November 27, 2023

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


valdy34
Level 2 ●●
Forum|alt.badge.img+10
  • Author
  • Level 2 ●●
  • 9 replies
  • November 27, 2023
Deepak wrote:

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


Deepak
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+44
  • 1549 replies
  • Answer
  • November 27, 2023

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


valdy34
Level 2 ●●
Forum|alt.badge.img+10
  • Author
  • Level 2 ●●
  • 9 replies
  • November 27, 2023
Deepak wrote:

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


Forum|alt.badge.img+6
  • Level 1 ●
  • 10 replies
  • January 4, 2024

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 

 


Deepak
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+44
  • 1549 replies
  • January 4, 2024

@philipangwk 

Try this

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


Forum|alt.badge.img+6
  • Level 1 ●
  • 10 replies
  • January 4, 2024

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!


Deepak
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+44
  • 1549 replies
  • January 4, 2024

Forum|alt.badge.img+6
  • Level 1 ●
  • 10 replies
  • January 4, 2024

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!

 

 


valdy34
Level 2 ●●
Forum|alt.badge.img+10
  • Author
  • Level 2 ●●
  • 9 replies
  • January 4, 2024

Deepak is the man!


Leave a Reply