Is there a universal way to get current question's value?

More
1 year 11 months ago #144349 by vkuzmin
vkuzmin created the topic: Is there a universal way to get current question's value?
Is there a universal way to get current question's value?
For example, i have 10 Short text questions named Q1-Q10. To check that their value isnt "1" i can type next string in Advanced settings - Logic - Question validation equation for every question:

Q1.NAOK!=1

I can get current question's ID with {SGQ}, but SGQ.value!=1, SGQ.NAOK!=1 or INSERTANS:SGQ!=1 won't work. Is there nothing like {CURRENT} that meat current question? I've tried also just '!=1' without left part but it won't work too.

Please Log in or Create an account to join the conversation.

More
1 year 11 months ago - 1 year 11 months ago #144352 by Joffm
Joffm replied the topic: Is there a universal way to get current question's value?
Hi, vkuzmin,
what do you want to do?
You want to validate the input when clicking "Next".

So, in the Validation field you do NOT enter the question ID, just the validation.
And according to the manual, short text is validated by a regular expression. See:
https://manual.limesurvey.org/Question_type_-_Short_free_text#Validation_.28using_regular_expressions.29_.28preg_validation.29

And if it is just a short text question put the validation into "General Options" / Validation"
E.g. this regular expression allows exactly one digit from 2 to 9.
/^[2-9]{1}$/
Best regards
Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last Edit: 1 year 11 months ago by Joffm. Reason: Ergänzung

Please Log in or Create an account to join the conversation.

More
1 year 11 months ago #144360 by tpartner
tpartner replied the topic: Is there a universal way to get current question's value?
In a short-text question, you can use the "self" variable to return the current question value - manual.limesurvey.org/Expression_Manager....27that.27_variables

self != 1

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: vkuzmin

Please Log in or Create an account to join the conversation.

More
1 year 11 months ago #144368 by vkuzmin
vkuzmin replied the topic: Is there a universal way to get current question's value?

tpartner wrote:

self != 1

Thank you! This is exactly what i need.

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!