Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:

THEMA: RegEx validate n-digit number

RegEx validate n-digit number 8 Monate 1 Woche her #105316

  • AndrejL
  • AndrejLs Avatar
  • OFFLINE
  • Bronze Donor
  • Beiträge: 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
Der Administrator hat öffentliche Schreibrechte deaktiviert.

RegEx validate n-digit number 8 Monate 1 Woche her #105343

  • DenisChenu
  • DenisChenus Avatar
  • OFFLINE
  • Moderator Lime
  • Beiträge: 6472
  • Dank erhalten: 854
  • Karma: 254
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 ....
Letzte Änderung: 8 Monate 1 Woche her von DenisChenu.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

RegEx validate n-digit number 8 Monate 1 Woche her #105362

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4297
  • Dank erhalten: 811
  • Karma: 374
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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Folgende Benutzer bedankten sich: DenisChenu, AndrejL

RegEx validate n-digit number 8 Monate 1 Woche her #105406

  • AndrejL
  • AndrejLs Avatar
  • OFFLINE
  • Bronze Donor
  • Beiträge: 35
  • Karma: 1
Indeed, that works perfectly!
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Moderatoren: ITEd
Ladezeit der Seite: 0.188 Sekunden
Donation Image