AnsweredAssumed Answered

Creating a constraint for 3 digits after the decimal in Survey123

Question asked by jakethepainter on Aug 6, 2019
Latest reply on Aug 8, 2019 by JTedrick-esristaff

I'd like to constrain user input in a decimal field (esri type double) to look like -0.123.  That is: either negative or positive, one digit before and 3 digits after the decimal.


I've got the following regular expression as a constraint:

regex(., '^[-]?\d[.]\d{3}$')

 

This works, except it won't allow a number like -1.100

 

The last digit has to be non-zero. If I switch the type of the field to text, it evaluates correctly, but that makes for a much less nice keyboard input on the ipad for the user.  I would like to keep the numeric keyboard.

 

Any ideas?  I'm fine with allowing -1 or -1.1 but don't want to allow 100.  I would prefer that the user have to type all 3 digits after the decimal.  I prefer to have them type the 0 before the decimal if the value is less than 1, but that's negotiable as well.

 

Good Values:

-1.234

-0.100

0.900

1.000

 

 

Bad values:

-10.123

100

-100

-.123 (negotiable)

-1 (negotiable)

-1.12

Outcomes