I have a survey which has several numeric input fields along the lines of 'How much did X cost?', but I can't for the life of me figure out how/where to validate the field to restrict to two decimal places (e.g. allow 12.55, but not 12.5, or 12.5555555)
I've been looking at RegEx I can't get it to work; I've tried putting it in 'Validation' ('/[0-9]+(\.[0-9][0-9]?)?/'), and in 'Question validation equation' (regexMatch('/[0-9]+(\.[0-9][0-9]?)?/')), but no joy.
We're running version 2.65.1+170522
Any help much appreciated - and apologies in advance if this is a stupid question.
If you need to disable 12.5 , and allow only 12.50 : you need a text question type (since 12.50 === 12.5 in numeric).
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. -
Professional support
-
Plugins, theme and development
. I don't answer to private message.
Sorry to resurrect an old request, but I have since identified an issue with the solution that was kindly offered up here.
regexMatch("/^\d+(\.\d{1,2})?$/", self) will indeed limit responses to integers or values with two decimal places, but if I apply it to a non-mandatory question, the field effectively becomes mandatory because null/no answer gets picked up by the validation.
Is there a way of amending this validation to allow for no response?