Welcome to the LimeSurvey Community Forum

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

Short text question validation: First sign must be capital letter second number

  • Otto12345
  • Otto12345's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 9 months ago #155403 by Otto12345
Hi,

I would like to create the following validation criteria for "Short free text" question: first sign must be capital letter A-Z and second sign must be number 0-9, everything else can be numbers. Is it possible to do this from the menu "Edit question -> Advanced settings -> Question validation equation"?

I tried some of the examples equations that are mentioned in the limesurvey manual but for some reason I could not get them to work (even when I just copypasted them). I would really appreciate if you would be able to tell me what I need to type in the "Question validation equation" box to get the rule working. Thank you in advance!
The topic has been locked.
More
6 years 9 months ago - 6 years 9 months ago #155407 by steve_81
Hello,

try this:

/^[A-Z][0-9]/
Last edit: 6 years 9 months ago by steve_81. Reason: ^ for starting at first position
The topic has been locked.
  • Otto12345
  • Otto12345's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 9 months ago #155409 by Otto12345
Thank you for the syntax! Unfortunately, it seems that I still have trouble getting the code to work properly. Here is a screenshot of the logic file.
Attachments:
The topic has been locked.
More
6 years 9 months ago #155411 by steve_81
Okay,

I'm using built 2.63 and there it ooks like this:



Which version do you use? Obviously the regex isn't recognized.
Maybe this works:
regexMatch("/^[A-Z][0-9]/")
Attachments:
The topic has been locked.
More
6 years 9 months ago #155412 by steve_81
Wait, I just see, that you inserted it in the Question-validation equation.
You have to insert it here:
The topic has been locked.
  • Otto12345
  • Otto12345's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 9 months ago #155413 by Otto12345
Thanks for the quick reply. It's working now! I was typing the equation into a wrong field like you said :D
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 9 months ago - 6 years 9 months ago #155416 by tpartner
You can use either the "Validation" or the "Question validation equation" fields. The "Question validation equation" allows for far greater flexibility in the validation criteria but requires the use of Expression Manager syntax.

Something like this (which also restricts any characters after the first two to be numeric):

Code:
regexMatch("/^[A-Z][0-9][0-9]*$/", this)

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 6 years 9 months ago by tpartner.
The following user(s) said Thank You: Otto12345
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose