Actions

QS

Em validation q/fr: Difference between revisions

From LimeSurvey Manual

(Updating to match new version of source page)
(Updating to match new version of source page)
Line 2: Line 2:
<onlyinclude>
<onlyinclude>


===Whole question validation equation (em_validation_q) ===
===Question validation equation (em_validation_q) ===
 
{{FeatureStarting/fr|v=1.92}}


'''Description'''
'''Description'''


This is an equation that is used to validate the entire question (e.g all of its parts collectively for a multi-answer question). If the question fails the validation criteria, then then em_validation_q_tip message has the CSS style .error set to it. This tip uses the .em_q_fn_validation CSS style, which is hidden by default within template.css.
This is an equation that is used to validate the entire question (e.g all of its parts collectively for a multi-answer question). If the question fails the validation criteria, then then em_validation_q_tip message will be displayed (it uses the CSS style .error). This tip uses the .em_q_fn_validation CSS style, which is hidden by default within template.css.


The main difference between this feature and the Sub-question 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 sub-question validation, each text entry cell (e.g. in array, but also applies to single entry question types) will be styled so that the background color is pink.
The main difference between this feature and the subquestion validation equations ([[QS:Em_validation_sq|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 array, but also applies to single entry question types) will be styled so that the background color is pink.


'''Valeurs possibles'''
'''Valeurs possibles'''


Tout texte, pour utiliser le[[Expression Manager/fr|gestionnaire d’expression]], il faut l'entourer d'accolades.
*Any equation that makes use of the [[Expression Manager|Expression Manager]] syntax, without surrounding curly braces.


'''Exemple'''
'''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 reasonable email and phone number.
*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 reasonable email and phone number.


This example shows how the question looks with invalid answers:
This example shows how the question looks with invalid answers:


[[File:validation-invalid-both.jpg]]
<center>[[File:validation-invalid-both.jpg]]</center>


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


[[File:validation-invalid-phone.jpg]]
<center>[[File:validation-invalid-phone.jpg]]</center>


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


[[File:validation-gui.jpg]]
<center>[[File:validation-gui.jpg]]</center>


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


[[File:validation-logic.jpg]]
<center>[[File:validation-logic.jpg]]</center>


As you can see, the validation equation tests that both the email and phone are either empty or match a regular expression filter.
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.
The validation tip only shows the warning message if the phone or email appears invalid.


Please see the forum for examples: https://www.limesurvey.org/forum/can-i-do-this-with-limesurvey/111858-validate-phone-and-email-in-multiple-short-text
{{Hint|Text=In order to create complex validation messages, read about the usage of the [[Expression Manager]].}}
 
If you wish import the example from above into your LimeSurvey installation, download the following .lsq file: [[File:Em validation q example.zip]]


{{Hint|Text=Remember, LimeSuvey uses the Perl syntax for regular expressions, so they should start and end with / (slash character)!}}
{{Hint|Text=Remember, LimeSuvey uses the Perl syntax for regular expressions, so they should start and end with / (slash character)!}}
</onlyinclude>
</onlyinclude>


[[Category:Question Settings/fr]][[Category:Advanced Question Settings/fr]]
[[Category:Question Settings]][[Category:Question Logic Options]]

Revision as of 15:40, 31 March 2018


Question validation equation (em_validation_q)

Description

This is an equation that is used to validate the entire question (e.g all of its parts collectively for a multi-answer question). If the question fails the validation criteria, then then em_validation_q_tip message will be displayed (it uses the CSS style .error). This tip uses the .em_q_fn_validation CSS style, which is hidden by default within 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 array, but also applies to single entry question types) will be styled so that the background color is pink.

Valeurs possibles

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

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 reasonable email 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 validate the accuracy of your expression and ensure 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 Expression Manager.


If you wish import the example from above into your LimeSurvey installation, download the following .lsq file: 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)!