Zero as decimal

Hello everybody,

I’m currently working on a form to collect field nutrition data for research.
I want to collect anthropometric data with a one decimal accuracy.
The problem is : with the constraint formula, the investigator can enter data without one decimal, and it’s a real issue for the exactitude.
After multiple attempts, I had to enter data with one decimal, but zero is not a permit value (65,0 for example).
Finally, I lmust have the possibility to enter data with 2 digits and 1 decimal where zero is a permit valule.
Thank you in advance for your advices.

Mélanie

Welcome @melanie_antoine,
Could you specify, please, in detail which entries (and ranges) you want to allow? E.g.

  • 0
  • 0.0
  • 1
  • 1.0
  • 0.1
  • .1
  • 9
  • 9.0
  • 9.9
  • 99
  • 99.0
  • 99.9
  • 0.9
  • .9
    etc.
2 Likes

I wish the investigateur can enter data with this accuracy : 9,9 or 99,9 or 999,9

I try with this constraint formula regex(., ‘[1]+.[0-9]+$’)
It work, but the decimal numbers are not limited. I want to limit decimal at one tenth.

Thank you for your help.


  1. 0-9 ↩︎

Hi @melanie_antoine, it seems you were almost there with your regex expression. Can you try this and see if it does what you’re needing:

regex(. '^[0-9]+\.[0-9]$')

If zero is not something you want, then:

regex(. '^[0-9]+\.[1-9]$')

If you want only two digits and allow for zero decimal value then:

regex(. '^[0-9]{2}\.[0-9]$')
1 Like