Welcome, Guest
Username: Password: Remember me

TOPIC: RegEx validate n-digit number

RegEx validate n-digit number 1 month 3 weeks ago #105316

  • AndrejL
  • AndrejL's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 35
  • Karma: 1
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
The administrator has disabled public write access.

RegEx validate n-digit number 1 month 3 weeks ago #105343

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 5830
  • Thank you received: 711
  • Karma: 220
Hi,

Not sure (i'm not a regexp expert ...)

But, maybe:
/^([0-9]{15}|[0-9]{9})$/

Denis
PS: oups, Tony read question better than me, my english is very poor ....
Last Edit: 1 month 3 weeks ago by DenisChenu.
The administrator has disabled public write access.

RegEx validate n-digit number 1 month 3 weeks ago #105362

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 3813
  • Thank you received: 683
  • Karma: 327
I think that will allow a 15-digit number or a 9-digit number.

How about:
/^([0-9]{15}|9)$/


.
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: DenisChenu, AndrejL

RegEx validate n-digit number 1 month 3 weeks ago #105406

  • AndrejL
  • AndrejL's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 35
  • Karma: 1
Indeed, that works perfectly!
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.168 seconds
Donation Image