Check out the LimeSurvey source code on GitHub!

Help Setting Conditions

More
5 years 7 months ago #63139 by Rowzdower
Hello - here is my challenge. My survey takers have to enter an alphanumeric code to gain access to the survey. It has four parts -- example (05-T7B4-8B39-0003). I want to set a condition based on only the first two digits. Is this possible (short of creating four separate fields on their own lines)? Second, if anyone can create me a Regular expression to validate this code, I'd greatly appreciate it. Thanks!

Please Log in to join the conversation.

More
5 years 7 months ago #63167 by jelo
Validation of the field (if the numbers and letters are always on the same position) could be done with this pattern:

/^\d\d-\w\w\w\w-\d\w\d\d-\d\d\d\d/

conditions on the first two digits would e.g mean to display a question when regex is true.

To match 05 in your example a working regex would be ^[0][5].
The following user(s) said Thank You: Rowzdower

Please Log in to join the conversation.

More
5 years 7 months ago #63176 by tpartner
Here's my crack at the regex for the whole string (also assuming that alphas an numerics must be in those positions).
/^\d{2}-\w\d\w\d-\d\w\d{2}-\d{4}$/

And maybe to simplify the conditions regex a bit, you only need:
^05

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: Rowzdower

Please Log in to join the conversation.

More
5 years 7 months ago #63190 by Rowzdower
This is perfect - thank you!!!

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form