Welcome to the LimeSurvey Community Forum

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

Subquestion validation equation for multiple short text question

  • ngolub
  • ngolub's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
2 months 3 weeks ago #255560 by ngolub
Please help us help you and fill where relevant:
Your LimeSurvey version:  LimeSurvey Community Edition   Version 6.4.0+231218 
Own server or LimeSurvey hosting: own server
Survey theme/template: bootstrap vanilla
==================
Hi I have a multiple short text type question and am trying to create a subquestion that will only allow numerical input.

My question's code is: "vorherigePos" and my subquestion code is "3".

I have tried this expression in the subquestion validation equation field but it did not work: preg_match('/^[0-9]+$/', vorherigePos_3.NAOK)

Can you help me find the correct code for this?

Thank you!
 

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 months 3 weeks ago #255561 by Joffm
Hi,
"preg_match" is not a valid function in LimeSurvey.
Please, read the manual about "implemented functions"

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: ngolub

Please Log in to join the conversation.

  • ngolub
  • ngolub's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
2 months 3 weeks ago - 2 months 3 weeks ago #255562 by ngolub
Thank you, will do! Do you happen to know what the correct validation equation would be for this problem?

I have tried this as well: regexMatch("/^[1-9][0-9]{0,4}$/", vorherigePos_3)
Last edit: 2 months 3 weeks ago by ngolub.

Please Log in to join the conversation.

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 months 3 weeks ago #255565 by DenisChenu
Seems OK, maybe regexMatch("/^[1-9][0-9]{0,4}$/", vorherigePos_3.NAOK) ?

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 following user(s) said Thank You: ngolub

Please Log in to join the conversation.

  • ngolub
  • ngolub's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
2 months 3 weeks ago #255566 by ngolub
Thank you. I tried that, but unfortunately, it did not work.

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 months 3 weeks ago #255567 by holch
What does "it did not work" mean exactly? What is the exact issue?

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

Please Log in to join the conversation.

  • ngolub
  • ngolub's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
2 months 3 weeks ago - 2 months 3 weeks ago #255568 by ngolub
I want the third answer option ("Anzahl Jahre:") to only accept a numerical input as a valid answer.

By "it did not work," I mean that the subquestion validation equation does not achieve this desired result. 

 
Last edit: 2 months 3 weeks ago by ngolub.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 months 3 weeks ago #255569 by Joffm
Yes, always try with something simple and test your equations by inserting them into the question text (with curly brackets)

You will find that "regexMatch" does not support this construct {0,4}
So an easy first workaround is
regexMatch("/^[1-9][0-9]*$/", Q1_3.NAOK) and Q1_3<100000
But here you get an initial error while the cell is still empty.
So add this and it is fine.
is_empty(Q1_3) or (regexMatch("/^[1-9][0-9]*$/", Q1_3.NAOK) and Q1_3<100000)

Or you only use comparisons like
is_empty(Q1_3) or (Q1_3>0 and Q1_3<100000)

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: ngolub

Please Log in to join the conversation.

  • ngolub
  • ngolub's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
2 months 3 weeks ago #255577 by ngolub
Thank you very much; this worked like a charm!

I have two follow-up questions:

1. Now, if a survey participant does not enter a number, a message appears saying they cannot proceed. How can I edit the text in the message?

2. All the response fields of the question are highlighted in red if the input is character instead of numeric. Is it possible to only have subquestion 3 highlighted in red, since 1 and 2 may have characters as input?

 
 

Thank you!

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 months 3 weeks ago #255580 by Joffm
1. What is wrong with this message?
You have a question validation tip that shows an error if the respondent enters something not valid.
If he ignores this and tries to proceed the above message is displayed.

Nevertheless,
maybe this helps
[url] forums.limesurvey.org/forum/design-issue...soft-warning-message [/url]

2. Yes, obvious, because the question validation fails. So the entire question is marked red.
You can redesign the question to show the error only in the subquestion,
but - to be honest - I am tired to answer here in English without necessity.

Ask it in the German part and we can discuss it without language gap

Joffm
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: ngolub

Please Log in to join the conversation.

  • ngolub
  • ngolub's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
2 months 2 weeks ago #255610 by ngolub
Thank you very much for your help!

Next time, I will ask in the German forum (I am new to LimeSurvey and did not even know that the German forum existed).

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose