Input Validation with regular expression fails

Plus d'informations
il y a 1 an 3 mois - il y a 1 an 3 mois #149223 par Bielefeld
Bielefeld a créé le sujet : Input Validation with regular expression fails
Hi,

I can't seem to get this working with the current LS Version 2.63.1+170305

Trying to validate input values (numeric or alphanumeric) via the "Validation"-Field
in Question-Editor. I try to use regular expressions, but even the simplest currently fail.

Example:
This expression should allow only *one* alphanumerical letter in lowercase (a-z),
and I specified the maximum occurrence of *one* character explicitly using {1}
/^([a-z]{1})$/

Of course, when I enter a number or a non-alphabetical character, the answer-box
gets a red frame, showing this is not correct. Okay. Now I enter a alphabetical letter
like "a": Okay! But when I continue entering more letters (or even numbers etc.), the
answer is still marked as correct, so no red frame anymore after the first correct letter.

In my opinion this behaviour is incorrect. I have tested this simple regex with some
online regex-machines (e.g.: regex101.com), and with these, my regex rules were okay -
for this example: one alpha letter was accepted, more than one were rejected.

I have played with many more regex rules, simple or more complex, and the current
regex validation mode of LS does not seem to work for me. Any suggestions?

Cheers,
Stefan

Version 2.63.1+170305
Pièces jointes :
Dernière édition: il y a 1 an 3 mois par Bielefeld. Raison: typo

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 1 an 3 mois #149224 par jelo
jelo a répondu au sujet : Input Validation with regular expression fails
Are you using your template modifications as stated in this thread:
www.limesurvey.org/forum/design-issues/1...-the-question#149217
  .em_regex_validation.emtip.good
  {
    display:none;
  }
 .em_regex_validation.emtip.error
  {
    display:none;
  }

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 1 an 3 mois #149225 par Bielefeld
Bielefeld a répondu au sujet : Input Validation with regular expression fails
Yes, I do. But with my example case, e.g. entering a "1" (numeric value)
I would still have this correctly classified as an error, so a red frame
around the incorrect answer will be displayed, see attachment...

Thanks for your input!

Version 2.63.1+170305
Pièces jointes :

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 1 an 3 mois #149226 par Bielefeld
Bielefeld a répondu au sujet : Input Validation with regular expression fails
Just cross checking:
Same regex behaviour with the original default template.
Any ideas?

Version 2.63.1+170305
Pièces jointes :

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 1 an 3 mois #149227 par jelo
jelo a répondu au sujet : Input Validation with regular expression fails

Bielefeld écrit: Just cross checking:
Same regex behaviour with the original default template.
Any ideas?

This looks like a bug in the Javascript-Validation. I'm not a RegEx-Expert but this look alright to me.
LimeSurvey is always doing validation on JS and PHP-Level.

So if you are executing your survey (instead of preview) the validation might be at least executed correctly on PHP level. You could try that and then submit a bugreport about your findings. It should be work on JS-Level. Perhaps the {} are now causing trouble after some regression in the code. We will see.

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 1 an 3 mois #149228 par Bielefeld
Bielefeld a répondu au sujet : Input Validation with regular expression fails
Thanks for your input!

Executing the survey live does not make any difference,
simplifying the regex to the absolute minimum like this:
/^[a-z]$/
does not make a difference either.

Your point of JS vs. PHP regex-validation is not clear to
me. Is it, that on some levels (preview perhaps) JS-regex
is used, and on other (live survey) PHP-regex is used?
This is not how I tried to understand the source code,
but I may be missing something important here!

Cheers,
Stefan

Version 2.63.1+170305

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 1 an 3 mois #149255 par tpartner
tpartner a répondu au sujet : Input Validation with regular expression fails
Please file a bug report supplying all details and a small test survey.

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 1 an 3 mois #149277 par jelo
jelo a répondu au sujet : Input Validation with regular expression fails

Bielefeld écrit: Your point of JS vs. PHP regex-validation is not clear to
me. Is it, that on some levels (preview perhaps) JS-regex
is used, and on other (live survey) PHP-regex is used?

Validation on page via JS (in the browser) and validation after hitting a button to submit page via PHP (on the server). The JS validation seems to be not working with your RegEx. I wondered what happen, when you enter a invalid answer (which isn't prevented by the JS-validation) and submit it to the server.
Will LS accept it or will LS trigger an error and enforce you to change the answer to comply to your RegEx.

The bugreport should be submitted either ways. Since if JS is available we want to catch these things on browser level.

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 1 an 3 mois - il y a 1 an 3 mois #149313 par Bielefeld
Bielefeld a répondu au sujet : Input Validation with regular expression fails
Thanks for your input!

It seems the error is on the JS side, since after activating
the survey and entering invalid data (being accepted by
the JS regex check), the server's answer is indeed, that
the data is not valid and should be changed. Good hint
to check that!

I have created a bug report as recommended
and attached a sample LS-export to reproduce.

Bugreport

In the below attachment you will find the same LS export
so you can test and maybe reproduce the effect with your system.

Cheers,
Stefan

Version 2.63.1+170305
Pièces jointes :
Dernière édition: il y a 1 an 3 mois par Bielefeld. Raison: typo

Connexion ou Créer un compte pour participer à la conversation.

Commencez dès maintenant !

Créez simplement un compte et commencez à utiliser LimeSurvey dès aujourd'hui.

Inscrivez-vous maintenant

Inscrivez-vous à notre Newsletter!