- Posts: 13
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
RegEx validate n-digit number
- AndrejL
- Topic Author
- Offline
- New Member
Less
More
10 years 3 weeks ago #105316
by AndrejL
RegEx validate n-digit number was created by AndrejL
Hi!
I would like LS to validate entry of a certain n-digit number (card id number9. For my case it must be a 15-digit number. But respondent must also have an option to enter just number 9 (if he doesn't know his card id number).
So only valid answers are digit 9 or any 15-digit number.
LS version on which survey is running is 1.91+.
I'm am aware of RegEx for 15-digit number /[0-9]{15}/ but I don't know how to let user to be able to enter digit 9 as well.
Thank you,
Andrej
I would like LS to validate entry of a certain n-digit number (card id number9. For my case it must be a 15-digit number. But respondent must also have an option to enter just number 9 (if he doesn't know his card id number).
So only valid answers are digit 9 or any 15-digit number.
LS version on which survey is running is 1.91+.
I'm am aware of RegEx for 15-digit number /[0-9]{15}/ but I don't know how to let user to be able to enter digit 9 as well.
Thank you,
Andrej
The topic has been locked.
- DenisChenu
- Away
- LimeSurvey Community Team
Less
More
- Posts: 13910
- Thank you received: 2546
10 years 3 weeks ago - 10 years 3 weeks ago #105343
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic RegEx validate n-digit number
Hi,
Not sure (i'm not a regexp expert ...)
But, maybe:
Denis
PS: oups, Tony read question better than me, my english is very poor ....
Not sure (i'm not a regexp expert ...)
But, maybe:
Code:
/^([0-9]{15}|[0-9]{9})$/
Denis
PS: oups, Tony read question better than me, my english is very poor ....
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Last edit: 10 years 3 weeks ago by DenisChenu.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3691
10 years 3 weeks ago #105362
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic RegEx validate n-digit number
I think that will allow a 15-digit number or a 9-digit number.
How about:
.
How about:
Code:
/^([0-9]{15}|9)$/
.
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: DenisChenu, AndrejL
The topic has been locked.
- AndrejL
- Topic Author
- Offline
- New Member
Less
More
- Posts: 13
- Thank you received: 0
10 years 3 weeks ago #105406
by AndrejL
Replied by AndrejL on topic RegEx validate n-digit number
Indeed, that works perfectly!
The topic has been locked.