Restrict decimal point to one

1. What is the issue? Please be detailed.

How do I restrict entry to only to one decimal point in ODK excel design? For exampe height 120.2 cm is valid but anything like 120 or 120.25 is invalid. Thanks
2. What steps can we take to reproduce this issue?

3. What have you tried to fix the issue?

4. Upload any forms or screenshots you can share publicly below.

Maybe the search function of this forum can help you, incl. examples, see https://forum.getodk.org/search?q=regex%20decimal%20digits, esp. Regex on decimal numbers with .0 e.g. 38.0.

Hints:
As far as I know, for decimal type, you cannot avoid that 12.0 will finally be shown as 12. (Also, this is mathematically the same value.)

You cannot restrict directly inside/during the field entry, only after the focus is moved outside (check via constraint).

For regex constraints, you can find more here: https://docs.getodk.org/form-regex. You can use a decimal or integer type and cast it with string(${myNumberVar}) for the regex expression.

2 Likes

image
So far that is what I have but it is still not allowing for example 125.0, it starts on 125.1 and above.
When I make the decimal optional but including(?) i.e regex(., '[1]+(.[0-9]{1})?$') and (.>=125 and .<=192) ,, it allows 125, 125.0, 125.1 ,...... but I strictly want it to start on 125.0 (It should be invalid if 125 is entered)


  1. 0-9 ↩ī¸Ž

As explained here, as far as I know, you cannot restrict 123, but allow 123.0. Furthermore, mathematically this is the same value. Even, if you may add a constraint for string-length(..) = 5.


Thanks ,
What you shared has been helpful,, I am now able to do want I wanted.

Regards,
AbelA

2 Likes