Welcome to the LimeSurvey Community Forum

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

Comment required depending upon choice selected

  • dmitsuo
  • dmitsuo's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 9 months ago - 8 years 9 months ago #121787 by dmitsuo
Hi everyone...

I have the following type of question:

========== BEGIN OF QUESTION
Question: Do you agree with blah blah blah ? If disagree, you must explain your answer on "Comments" field.
Choices (only one choice):
1. Agree
2. Disagree
3. Partially disagree

Comments: ____________________________
========== END OF QUESTION

The "Comments" field is optional by default, but if choice 2 (Disagree) is selected, the "Comments" fields should be required.

How do I do that?

Thanks in advance!
Last edit: 8 years 9 months ago by dmitsuo. Reason: typo
The topic has been locked.
  • gabrieljenik
  • gabrieljenik's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
8 years 9 months ago #121788 by gabrieljenik
Replied by gabrieljenik on topic Comment required depending upon choice selected
You can make use of the validation equation.
Something like this should work:
self.NAOK != 2 || (self.NAOK == 2 && strlen(self.comments) > 0 )
Explanation: Either answer is different from 2 or answer is 2 and a comment was entered.

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Checkout our Reporting Solutions and our plugin shop at www.encuesta.biz .

The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose