Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Decimal places in answer

  • jimdavies
  • jimdavies's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
5 years 8 months ago #171635 by jimdavies
Decimal places in answer was created by jimdavies
How can I force an answer to be a numerical value with 2 decimal places?

This is the question "Provide the current program scorecard score for the program you manage."
I need the participants to answer 97.95, for example.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 8 months ago #171636 by Joffm
Replied by Joffm on topic Decimal places in answer
Hi,
you can validate the question (numerical) with is_empty(self) OR regexMatch('/^[0-9]+(\.[0-9][0-9])$/',self)

Best regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: DenisChenu
The topic has been locked.
  • jimdavies
  • jimdavies's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
5 years 8 months ago #171637 by jimdavies
Replied by jimdavies on topic Decimal places in answer
Do I need to add some advanced settings? When I preview the survey it allows me to put in anything, it doesn't force 2 decimals.
Attachments:
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 8 months ago #171644 by DenisChenu
Replied by DenisChenu on topic Decimal places in answer
Question validation (and you can set the tip)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 8 months ago - 5 years 8 months ago #171662 by Joffm
Replied by Joffm on topic Decimal places in answer
Hi,

When I preview the survey it allows me to put in anything, it doesn't force 2 decimals.

Yes, you can put in anything - but you cannot proceed.

With this settings:


you will get:






Best regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 5 years 8 months ago by Joffm.
The topic has been locked.
  • jimdavies
  • jimdavies's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
5 years 8 months ago #171693 by jimdavies
Replied by jimdavies on topic Decimal places in answer
Could you paste in the question validation tip so I can copy and paste it?
The topic has been locked.
  • jimdavies
  • jimdavies's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
5 years 8 months ago #171695 by jimdavies
Replied by jimdavies on topic Decimal places in answer
I added the question validation tip but it's not working like in your screen shots. Attached is what I have for the question and the result I get
Attachments:
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 8 months ago #171699 by DenisChenu
Replied by DenisChenu on topic Decimal places in answer
Look at the picture of Joffm please :


you leave the test on Validation : you must remove it from here …

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 8 months ago #171727 by Joffm
Replied by Joffm on topic Decimal places in answer
Hi,
you put the validation in "validation"; you should have put it into "question validation equation"
and there is a missing quote before the "positive" tip.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: jimdavies
The topic has been locked.
  • jimdavies
  • jimdavies's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
5 years 8 months ago #171745 by jimdavies
Replied by jimdavies on topic Decimal places in answer
I was able to get it to work on question #3 but it's not working on question #5. When I preview the question it appears to work but when I preview the survey I get a red exclamation mark. I compared the validation code and they appear to match between #3 and #5. Only diff I see is #5 has a condition.
Attachments:
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose