Welcome, Guest
Username: Password: Remember me

TOPIC: Help Setting Conditions

Help Setting Conditions 3 years 1 month 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 3 years 1 month ago #63167

  • jelo
  • jelo's Avatar
  • OFFLINE
  • Platinum Lime
  • Posts: 467
  • Thank you received: 52
  • Karma: 16
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

Re: Aw: Help Setting Conditions 3 years 1 month ago #63176

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4127
  • Thank you received: 761
  • Karma: 347
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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.
The following user(s) said Thank You: Rowzdower

Re: Aw: Help Setting Conditions 3 years 1 month 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.111 seconds
Donation Image