Welcome to the LimeSurvey Community Forum

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

VALIDATIONS

  • Steven123
  • Steven123's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 9 months ago #201764 by Steven123
VALIDATIONS was created by Steven123
Hello!


Kindly help to validate ID number, it should have 9 numbers and the 5th number should be 1 or 2 depending on the gender chosen, 1 for male and 2 for female.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 9 months ago #201768 by Joffm
Replied by Joffm on topic VALIDATIONS
Not necessary to open a new thread.

(QGender==1 and regexMatch('/^[0-9]{4}[1][0-9]{4}$/',self.NAOK)) OR (QGender==2 and regexMatch('/^[0-9]{4}[2][0-9]{4}$/',self.NAOK))

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.
  • Steven123
  • Steven123's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 9 months ago #201964 by Steven123
Replied by Steven123 on topic VALIDATIONS
Hello!

Its not working, i used code and answer on my validation area but its not working. see my attached screen shot.
Attachments:
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 9 months ago - 3 years 9 months ago #201968 by Joffm
Replied by Joffm on topic VALIDATIONS
Well,
which question type did you use for the gender question?
"gender" or "list(radio)"?
If "list(radio)", which codes did you use?

My example is for a "list(radio)" coded "1 = male, 2 = female"
If you did someting different you have to adapt the validation equation.

AND: you have to enter this in the "question validation equation" in section "Logic".

Joffm




Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 3 years 9 months ago by Joffm.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 9 months ago #201970 by DenisChenu
Replied by DenisChenu on topic VALIDATIONS
Don't use validation : use Question validation equation

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.
  • Steven123
  • Steven123's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 9 months ago #202337 by Steven123
Replied by Steven123 on topic VALIDATIONS
Hello!

I'm failing to make it work, i have changed to list radio but still failing and i have entered in the validation equation" in section "Logic". See my attachments and advice.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 9 months ago - 3 years 9 months ago #202351 by tpartner
Replied by tpartner on topic VALIDATIONS
You have used the wrong answer codes.

The validation equation should be:

Code:
(q34 == "A1" and...) OR (q34 == "A2" and...)

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 3 years 9 months ago by tpartner. Reason: Typo
The topic has been locked.
  • Steven123
  • Steven123's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 9 months ago #202352 by Steven123
Replied by Steven123 on topic VALIDATIONS
Hello

Still not working see bellow.

(q34=="A1" and regexMatch('/^[0-9]{4}[1][0-9]{4}$/',self.NAOK)) OR (q34=="A2" and regexMatch('/^[0-9]{4}[2][0-9]{4}$/',self.NAOK))
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 9 months ago #202354 by Joffm
Replied by Joffm on topic VALIDATIONS
Obviously you do something wrong.

So instead of saying "doesn't work" you should send your survey as lss export.
How can we know what you do?

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • Steven123
  • Steven123's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 9 months ago #202355 by Steven123
Replied by Steven123 on topic VALIDATIONS
Hello!

I have attached.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 9 months ago - 3 years 9 months ago #202357 by Joffm
Replied by Joffm on topic VALIDATIONS
1. What is this in q34?

(Gender==1 and regexMatch('/^[0-9]{4}[1][0-9]{4}$/',self.NAOK)) OR (Gender==2 and regexMatch('/^[0-9]{4}[2][0-9]{4}$/',self.NAOK))

a. There is no question with code "Gender"
b. q34 (Gender has answer codes "A1" and "A2".
c. You want to validate "omang number".

Though the design of the survey is really bad - you display "group by group", but all questions are in one group.
Better to structure your questionnaire a bit
E.g. one group "address" with multiple short text
And more explanations, what and how to enter data

Okay, "omang number.
If I complete the questionnaire entering a wrong number I get this at the end.


and nobody knows the meaning, where there was an error.

So at least you should enter a hint there
like "Format: XXXX{if(q34=="A1","1","2")}XXXX"




Here something to read about survey design:
www.surveyfriendly.com/ppt/surveyfriendly1.pdf

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 3 years 9 months ago by Joffm.
The topic has been locked.
  • Steven123
  • Steven123's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 9 months ago #202358 by Steven123
Replied by Steven123 on topic VALIDATIONS
Hi!

I want to validate Omang Number depending on what i have selected at q34 which is the code for Gender. I will reorder after the question later
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose