Hi! I suggest you try the inputMask column in your XLSForm. You can find info about inputMaks in this help topic. It looks like a value of 9.9 in your inputmask would do the trick.
The input mask controls user input as values are entered in the input box. Incorrect values are shown in red, but once you have a value that matches the mask it will switch to black.
Another approach is to use a regular expression in the constraint column.
By the way! Once you can spell Survey123 without a space between Survey and 123, you qualify as a Survey123 Ninja.
What about specifying the scale on a decimal for calculated values. inputMask seems to only work when you know the precision and scale, like a percent (99.9%). I need to show 1 place past decimal even if it is 0; .1, 1.0 or 200.0 needs to be allowed. The round function knocks off the 0, but I need to show scale of 1 no matter.
I have this question too. I want to restrict the users to one decimal place but let the user input something like 30.3 or 3.1 without having to write 03.1, because the survey users won't know what the precision and scale is. Has anyone ever found a work around to this?
What do you mean above by putting a regular expression in the constraint column? Would we have to put in all the possibilities such as 0.1, 0.2, 0.3............99.9 etc?
You could restrict users to one decimal place using a regular expression in the constraint column.
This regular expression, for example, allows the user to input between 1 and 10 numbers before the decimal, and 1 after:
regex(., '^[0-9]{1,10}\.[0-9]{1}$')
This page has some details and examples dealing with regular expressions:
That is a great idea, thank you!
Hello. I tried entering the regular expression above in the Constraint field and it doesn't seem to work. The Type field is set to decimal. I'm trying to have the users enter a value from 0 to 99 and include 1 decimal place only. I've also entered 99.9 in the Input Mask field, but that forces the users to enter a leading 0 for values less then 10. Any help would be appreciated.
Hi Paul,
I tested the regex above and it is working properly- the constraint appears when I press the 'validate' button in Connect.
James, I figured out that in order for the constraint to work, you need to press the 'validate'...rookie move on my part. Thanks for the confirmation.
Tried this constraint, it works but it will not let you enter a decimal value of '0'. The following expression worked for me: regex(., '^\d{0,2}(?:\.\d)?$'). In this way the decimal is optional, so you can just leave it as a whole integer if you want.