Welcome to the LimeSurvey Community Forum

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

Question validation Tip

  • pvdemael
  • pvdemael's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
9 years 1 month ago #116476 by pvdemael
Question validation Tip was created by pvdemael
Hi,

I have question on using the question validation and question validation tip.

I have the following questions in my survey:
- numerical question: qVal
- array with 1 subquestion and 5 radio buttons with codes 1 to 5: qList

I would like to validate the qList as follows: if qVal=0 and qList option 4 or 5 are selected, the question is not validated and a tip should be shown


I inputted the following when editing the qList question:
Code in the question validation box:
!(intval(qVal.value)==0 and sum(self.NAOK)>3)

Code in the question validation tip box:
{if(intval(qVal)==0 and sum(self.NAOK)>3, 'Invalid choice', 'Valid choice')}

The string 'Valid choice' is always displayed, but only in red when the question is not valid so the validation works, but not the tip.

Anyone an idea?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 1 month ago - 9 years 1 month ago #116507 by tpartner
Replied by tpartner on topic Question validation Tip
That seems to be a bug. The if() statement in the question validation tip is only evaluated on page load, not dynamically as the questions are answered.

Please file a bug report and...
  1. Give as much information as possible.
  2. Provide step-by-step instructions how to reproduce the problem.
  3. Provide screenshots and/or a sample survey.
  4. Post the link to the bug here so we can follow the progress.

As a workaround, you could add something like this to the source of the array question:

Code:
{if(intval(qVal.value)==0 and sum(self.NAOK)>3, '<span style="color:red;">Invalid choice</span>', '<span style="color:green;">Valid choice</span>')}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 9 years 1 month ago by tpartner.
The following user(s) said Thank You: pvdemael
The topic has been locked.
  • pvdemael
  • pvdemael's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
9 years 1 month ago #116579 by pvdemael
Replied by pvdemael on topic Question validation Tip
I've filed a bug report:
bugs.limesurvey.org/view.php?id=9475
The topic has been locked.
  • Mazi
  • Mazi's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
9 years 1 month ago #116641 by Mazi
Replied by Mazi on topic Question validation Tip

tpartner wrote: That seems to be a bug. The if() statement in the question validation tip is only evaluated on page load, not dynamically as the questions are answered.

Could this be a question type or EM function related issue?

...because I just worked on a similar setup (email validation) and there the EM expression was adjusted at runtime depending on the user input.

Great workaround BTW!

Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose