Welcome to the LimeSurvey Community Forum

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

Multiple numerical input - Setting range condition

  • AnneBastin13
  • AnneBastin13's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 2 months ago #179363 by AnneBastin13
Hi,

I am using LS web-based version 2.06+ Build 151215 and I am also quite new to programming.

I am trying to set conditions for a multiple numerical input. It is asking for height in m/cm or ft/in. Minimum answer is 2, maximum answer is 2 as well, although I didn't know how to relate meters with cm and feet with inches...

My problem is that I want to set a range:
max 2 meters, max 99cm
max 7 feet, max 11 inches


I can access the subquestion relevance, but if I enter, say G9Q00002_1 < 2 (I.E. question_subquestion <2) and so on for the next, when I test the question, if I enter a wrong number in meters (ex. 3), the input disappears!

I tried to enter ((G9Q00002_1 < 2 && G9Q00002_2 <100) || (G9Q00002_3 < 7 && G9Q00002_4 < 12)) But then the whole question would not show up. If I code this in the validation, then the question doesn't work at all

I think I am not using relevance/validation equations properly.

What can I do so user doesn't enter like 99m 1cm or ridiculous things like that?

Thank you all!

Anne
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 1 month ago - 5 years 1 month ago #179899 by Joffm
Hi, one short answer:

((G9Q00002_1 < 2 && G9Q00002_2 <100) || (G9Q00002_3 < 7 && G9Q00002_4 < 12))

is not sufficient

You did not tell us, but you seem to use "multiple numeric" with subquestion codes 1,2,3,4.
Enter into question validation equation:
(!is_empty(G9Q00002_1) AND !is_empty(G9Q00002_2) AND G9Q00002_1<2 AND G9Q00002_2<100) OR (!is_empty(G9Q00002_3) AND !is_empty(G9Q00002_4) AND G9Q00002_3<7 AND G9Q00002_4<12)

Maybe better to use: array(numbers).
Then
(!is_empty(G9Q00002_SQ001_1) AND !is_empty(G9Q00002_SQ001_2) AND G9Q00002_SQ001_1<2 AND G9Q00002_SQ001_2<100) OR (!is_empty(G9Q00002_SQ002_1) AND !is_empty(G9Q00002_SQ002_2) AND G9Q00002_SQ002_1<7 AND G9Q00002_SQ002_2<12)


Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 5 years 1 month ago by Joffm.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose