Actions

QS

QS:Em validation q

From LimeSurvey Manual

Revision as of 07:47, 28 September 2023 by Maren.fritz (talk | contribs) (Created page with "Il s'agit d'une équation utilisée pour valider la question dans son ensemble (par exemple, toutes ses parties collectivement pour une question à réponses multiples). Si la...")


Équation de validation de question (em_validation_q)

Description

Il s'agit d'une équation utilisée pour valider la question dans son ensemble (par exemple, toutes ses parties collectivement pour une question à réponses multiples). Si la question ne répond pas aux critères de validation, alors le message em_validation_q_tip sera affiché (il utilise le style CSS .error). Cette astuce utilise le style CSS .em_q_fn_validation, qui est masqué par défaut dans template.css.

The main difference between this feature and the subquestion validation equations (em_validation_sq option) is that for this feature, if the question (or question parts) fail validation, then an error message could be shown. For the subquestion validation, each text entry cell (e.g., in an array question type, but it can also be applied to single entry question types) will be styled so that the background color is (light) red.

Valeurs possibles

Tout texte, pour utiliser legestionnaire d’expression, il faut l'entourer d'accolades.

Exemple

  • You want to collect demographic information from users via a multiple short text question, and you want to validate that the user has entered a valid email address and phone number.

This example shows how the question looks with invalid answers:

And here is what it looks like with one invalid answer:

Here is how you edit a question to enter that information:

And here is part of the Show Logic File output that lets you check the accuracy of your expression and ensure that there are no syntax errors:

As you can see, the validation equation tests that both the email and phone number are either empty or match a regular expression filter.

The validation tip only shows the warning message if the phone or email appears invalid.

 Hint: In order to create complex validation messages, read about the usage of the ExpressionScript.


If you wish to import the example from above into your LimeSurvey installation, download the following .lsq file: Em_validation_q_example.zip.

 Hint: Remember, LimeSuvey uses the Perl syntax for regular expressions, so they should start and end with / (slash character)!



Another slightly different example can be downloaded below. It states that none of the three subquestion fields can be empty at the same time and that at least one of them has to be filled in (according to its corresponding regular expression). Download the question from here.