Require 2 Decimal Places in Text Response | XM Community
Skip to main content
Solved

Require 2 Decimal Places in Text Response

  • June 14, 2023
  • 3 replies
  • 568 views

Forum|alt.badge.img+2

I am working on a survey where individuals must enter monetary values. I would like to require all responses to have two decimal places (even if it needs to be .00) to prompt all respondents to enter the “cents”.

I see the option to have a “maximum” number of decimal places, but I don’t see an option for minimum number. Is there a way to require two decimal places? (As a note, the values can range from XXXX.XX all the way up to XXXXXXX.XX).

Thank you for your help!

Best answer by Deepak

@kgc_unc 

Instead of using normal validation use custom validation for entry to match regex to below value and give an error or instructions to have 2 decimal places.

^\d+\.\d{2}$

Hope it helps!

3 replies

EmilyErickson
Level 5 ●●●●●
Forum|alt.badge.img+13
  • Level 5 ●●●●●
  • 63 replies
  • June 14, 2023

You can’t require minimum decimals, only maximum decimals.


Deepak
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+46
  • 1555 replies
  • Answer
  • June 14, 2023

@kgc_unc 

Instead of using normal validation use custom validation for entry to match regex to below value and give an error or instructions to have 2 decimal places.

^\d+\.\d{2}$

Hope it helps!


Forum|alt.badge.img+2
  • Author
  • 1 reply
  • June 14, 2023

@Deepak that worked! Thank you so much!