Actions

QS

QS:Em validare q

From LimeSurvey Manual

Revision as of 09:44, 31 October 2023 by Maren.fritz (talk | contribs) (Created page with "Aceasta este o ecuație care este utilizată pentru a valida întreaga întrebare (de exemplu, toate părțile sale în mod colectiv pentru o întrebare cu mai multe răspunsu...")


Ecuația de validare a întrebării (em_validation_q)

Descriere

Aceasta este o ecuație care este utilizată pentru a valida întreaga întrebare (de exemplu, toate părțile sale în mod colectiv pentru o întrebare cu mai multe răspunsuri). Dacă întrebarea nu respectă criteriile de validare, atunci va fi afișat mesajul em_validation_q_tip (folosește stilul CSS .error). Acest sfat folosește stilul CSS .em_q_fn_validation, care este ascuns în mod implicit în 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.

Valid values

  • Any equation that makes use of the ExpressionScript syntax, without surrounding curly braces.

Example

  • 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.