j.biendaraconterra-de-esridist

Format for decimal numbers

Discussion created by j.biendaraconterra-de-esridist Employee on Aug 3, 2018
Latest reply on Aug 6, 2018 by j.biendaraconterra-de-esridist

Hello,

 

I am using a "decimal" question type and want to restrict the answers to a certain range and to a specific format:

  • Only values between 0 and 14
  • Up to two leading digits (before decimal separator)
  • Up to two decimal places
  • Decimal separator optional when no decimal places
  • No leading zero

 

I have tried various options, but none was completely satisfying.

 

Constraint

With a constraint like ". >= 0 and . <= 14" it is not possible to restrict the number of decimal places.

 

Input Mask

The input mask enforces the answer to exactly match the mask, i. e. the value 1 for the input mask 99.99 would require the answer 01.00, otherwise the answer fails validation.

 

Regex

I cannot think of any regular expression that fulfills all above mentioned restrictions since it has to do two things: Set limits to the allowed values (0 <= x <= 14) and also format the answer correctly. Moreover, I have the impression that in Survey123 regular expressions don't work correctly when applied to a decimal question.

 

So, what I need is a combination of constraint and

  • either input mask -> which would need to be more flexible (e. g. not enforcing the answer to exactly match the mask)
  • or regular expression
  • or the possibility to delimiter the number of digits before and after the decimal separator.

 

Does anyone have an idea how to deal with this?

Are there any enhancements planned for a future version of Survey123?

Right now, is it possible to combine a value limiting constraint and a regular expression (I was not successful with my tests)?

 

Thank you very much, best regards,

Jürgen

Outcomes