Welcome, Guest
Username: Password:

TOPIC: Help Setting Conditions

Help Setting Conditions 4 years 9 months ago #63139

  • Rowzdower
  • Rowzdower's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 5
  • Karma: 0
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!
The administrator has disabled public write access.

Aw: Help Setting Conditions 4 years 9 months ago #63167

  • jelo
  • jelo's Avatar
  • Offline
  • Platinum Donor
  • Posts: 1117
  • Thank you received: 134
  • Karma: 41
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 administrator has disabled public write access.
The following user(s) said Thank You: Rowzdower

Aw: Help Setting Conditions 4 years 9 months ago #63176

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5771
  • Thank you received: 1255
  • Karma: 514
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 administrator has disabled public write access.
The following user(s) said Thank You: Rowzdower

Aw: Help Setting Conditions 4 years 9 months ago #63190

  • Rowzdower
  • Rowzdower's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 5
  • Karma: 0
This is perfect - thank you!!!
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.657 seconds