Welcome to the LimeSurvey Community Forum

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

Validating just a subquestion in an array text question

More
7 years 4 months ago #167469 by mfiora
Hello,
i'd need an answer to a subquestion in an array text question to match a regular expression.
I looked around finding a way but simply could not.
First of all, where should i set it? In the question validation or in the sub-question validation?
I found out the SGQ(row and column) identifier but any test could not help.
Could you please provide me with an example?
Thank you very much.
The topic has been locked.
More
7 years 4 months ago - 7 years 4 months ago #167473 by Joffm
Hello, mfiora,

Could you please provide me with an example?


The other way: You should provide us with an example (*.lss).
That we exactly know what you are trying to achieve.

Best regards
Joffm

P.S. Without knowing more I can say:
in the question validation you can to access this special field by something like
Q1_SQ001_A3
Q1= Question code
SQ001 = Subquestion code (y-axis)
A3 = code of x-axis

Q1_SQ001_A3=="lorem ipsum" validates this field to this special text.
In your case it will be something like this in "question validation":
is_empty(self.sq_SQ001_A3) or regexMatch('/^[1-9]{1,3}$/',self.sq_SQ001_A3)

More explanation about this:
www.limesurvey.org/manual/Expression_Man....27that.27_variables

and:
www.limesurvey.org/manual/Expression_Man..._with_X_and_Y_scales

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 7 years 4 months ago by Joffm.
The topic has been locked.
More
7 years 4 months ago #167477 by mfiora
Hello Joffm and thanks for your reply,
You can see attached the test survey. I would like the fiscal code to match the regular expression
Code:
/^(\w{6}\d{2}\w\d{2}\w\d{3}\w)|(\d{11})$/

and highlight the field if it doesn't match.

I still am confused on where should i put the code you provided me with, sorry.

Thanks
The topic has been locked.
More
7 years 4 months ago #167479 by Joffm
Hi, mfiora,

1. you were confused about the syntax "self.sq_Y-X"
The first is the code of the y-axis, the second of the x-axis.
Because you named the y-axis "1", "2", "3", and the x-ais "SQ001" you entered a wrong statement.

And you enter it in

I assume there will be more columns - otherwise you should have used a "multiple short text" question.
So you have to o this for all columns:
(is_empty(self.sq_3_SQ001) or regexMatch('/^(\w{6}\d{2}\w\d{2}\w\d{3}\w)|(\d{11})$/',self.sq_3_SQ001)) AND
(is_empty(self.sq_3_SQ002) or regexMatch('/^(\w{6}\d{2}\w\d{2}\w\d{3}\w)|(\d{11})$/',self.sq_3_SQ002)) AND
(is_empty(self.sq_3_SQ003) or regexMatch('/^(\w{6}\d{2}\w\d{2}\w\d{3}\w)|(\d{11})$/',self.sq_3_SQ003))


2. Example (a correct code)


something else



Best regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
More
7 years 4 months ago #167480 by mfiora
Hello Joffm,
i found out. First there was some confusion between X and Y axis. Then i probably got lost in translation because you typed "Question validation" and i thought about "validation" field, but it was "Question validation equation".
And i also found a problem in Regexp.
Now it works.

Thanks for your support and patience.
The topic has been locked.
More
7 years 4 months ago - 7 years 4 months ago #167481 by Joffm
Hi, mfiora,

sorry,
yes, I know: I always wite "question validation" and "subquestion validation" instead of "... equation"

But nevertheless, I learned about Italian fiscal codes.
Nobody knows when I will need this knowledge.;)

Best regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 7 years 4 months ago by Joffm.
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose