Welcome to the LimeSurvey Community Forum

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

Mutiple short text - subquestion validation: only letters & only one character

  • Vinicos
  • Vinicos's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
4 years 2 days ago #197165 by Vinicos
Hello,

I have a multiple short text question with 3 subquestions. I want all of them to be validated only with letters and I want the first and the third to be validated with one character only. How can I do that?
LS version: 3.17.7+190627

Thanks
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 2 days ago - 4 years 2 days ago #197167 by tpartner

I want all of them to be validated only with letters

Place this in the "Subquestion validation equation" field:

Code:
is_empty(this) OR regexMatch('/^[a-zA-Z]+$/', this)

I want the first and the third to be validated with one character only

Place this in the "Question validation equation" field (assuming that the first and third sub-question codes are SQ001 and SQ003):

Code:
(is_empty(self.sq_SQ001) OR strlen(self.sq_SQ001) < 2) AND (is_empty(self.sq_SQ003) OR strlen(self.sq_SQ003) < 2)

Sample survey attached:

File Attachment:

File Name: limesurvey...3811.lss
File Size:21 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 4 years 2 days ago by tpartner.
The topic has been locked.
  • Vinicos
  • Vinicos's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
4 years 1 day ago #197189 by Vinicos
Thanks again!
It works perfectly.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose