Hello everyone, I’m new to the application, I need to solve something. In the decimal number, I need to place 2 numbers before the point, they can be negative or positive and after the point that are 5 mandatory digits. Please help.
Hi @julirami225, welcome to the community!
I think this will solve your issue:
regex(., '^\d{2}\.\d{5}$')
Here is a detailed help article on how to apply regex
:
https://support.kobotoolbox.org/restrict_responses.html
If you need further help, don’t hesitate to ask
Best,
Thank you very much for your help, I checked but I did not find how to restrict to placing the first negative or positive number, like this:
-0.12345
0.12345
Let it work both ways. If you can help me I would really appreciate it.
@julirami225, could you also share some possible input values that you wish to have for this? Initially you wanted to restrict 2 digits before the decimal point but in the later post it seems like you could also have one decimal digit before the decimal point.
@Kal_Lam Sorry for the confusion in the previous post, the data I want to enter exactly is 2 digits (positive or negative) before the comma and 5 digits (positive) after the comma.
Example:
-12,34567
12,34567
Thank you very much for your kind help.
Hi @julirami225,
Can you try this one, this shoul let you put -
before 2 digits, then a point .
then 5 digits.
regex(., ‘^-?\d{2}.\d{5}$’)
This will accept exactly 2 digits before point and exactly 5 digits after point.
Let’s see if that works.
@julirami225, or if you still need the value in a number format, you could use the demical
question type in the solution shared by @hakan_cetinkaya. It should be as shown in the image shared below:
In the survey tab of your XLSForm:
Reference XLSForm:
Decimal.xlsx (9.2 KB)
@Kal_Lam @hakan_cetinkaya It worked great, thank you very much.