Regex validation not working

More
3 years 11 months ago #96629 by nuin
nuin created the topic: Regex validation not working
Hi

We have a survey where users have to enter certain ID that can be recorded on the survey. Currently, our ID is a three-part string with a fixed initial prefix, a three-letter symbol followed by three numbers. Something like this:

CBN01_XXX_999

the three letter middle follows a strict rule and has 6-7 possibilities only, so our regex is

regexMatch(CBN01_[CQUTM][MUGWBCS][MHECAT]_[0-9][0-9][0-9])

I am using this on the Validation box of the question, and it does not seem to be working as, non allowed three-letter combinations are being accepted. I also tested this on the question validation equation box, with no success. The latter even makes a Javascript based mask for the field disappear.

Any help is appreciated.

Please Log in to join the conversation.

More
3 years 11 months ago #96630 by gimletbiggles
gimletbiggles replied the topic: Regex validation not working
You need forward slashes and quotes:

regexMatch('/CBN01_[CQUTM][MUGWBCS][MHECAT]_[0-9][0-9][0-9]/')

But, the validation box already has regexMatch implemented, so just use:

/CBN01_[CQUTM][MUGWBCS][MHECAT]_[0-9][0-9][0-9]/
The following user(s) said Thank You: nuin

Please Log in to join the conversation.

More
3 years 11 months ago #96631 by nuin
nuin replied the topic: Regex validation not working
Thanks a lot, works perfectly.

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now