Actions

QS

QS:Em validation q

From LimeSurvey Manual

Revision as of 07:24, 14 August 2023 by Maren.fritz (talk | contribs) (Created page with "'''Gültige Werte'''")


Fragenvalidierungsgleichung (em_validation_q)

Beschreibung

Dies ist eine Gleichung, die verwendet wird, um die gesamte Frage zu validieren (z. B. alle ihre Teile zusammen für eine Frage mit mehreren Antworten). Wenn die Frage die Validierungskriterien nicht erfüllt, wird die Meldung em_validation_q_tip angezeigt (sie verwendet den CSS-Stil .error). Dieser Tipp verwendet den CSS-Stil .em_q_fn_validation, der standardmäßig in template.css ausgeblendet ist.

Der Hauptunterschied zwischen dieser Funktion und den Validierungsgleichungen für Unterfragen (em_validation_sq-Option) besteht darin, dass bei dieser Funktion eine Fehlermeldung angezeigt werden kann, wenn die Validierung der Frage (oder der Fragenteile) fehlschlägt. Für die Unterfragevalidierung wird jede Texteingabezelle (z. B. in einem Array-Fragentyp, kann aber auch auf Einzeleingabe-Fragetypen angewendet werden) so gestaltet, dass die Hintergrundfarbe (hell)rot ist.

Gültige Werte

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