Welcome to the LimeSurvey Community Forum

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

Multiple short text answer different conditions for each box?

  • wilmslow3
  • wilmslow3's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 6 months ago #143694 by wilmslow3
Just wondering is there a way to have conditions of what is entered into each short text box.

I would ilke one to only contain characters (A-Z) and the second box to only contain numbers (0-9)

Is there a way to do this via regular expression?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 6 months ago #143697 by tpartner
Assuming sub-question codes SQ001 and SQ002, you could place something like this in the "Question validation equation":
Code:
regexMatch('/^[A-Za-z]*$/', self.sq_SQ001) AND regexMatch('/^[0-9]*$/', self.sq_SQ002)

And something like this in the "Question validation tip":
Code:
{if(regexMatch('/^[A-Za-z]*$/', self.sq_SQ001) AND regexMatch('/^[0-9]*$/', self.sq_SQ002), '', 'Please enter values in the correct format.')}

manual.limesurvey.org/Expression_Manager#Access_to_Functions

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: wilmslow3
The topic has been locked.
  • wilmslow3
  • wilmslow3's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 6 months ago #143713 by wilmslow3
Thanks tpartner :-)
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose