Actions

QS

Em validation sq: Difference between revisions

From LimeSurvey Manual

(Created page with "<translate> <!--T:1--> <languages /> <onlyinclude> ===Sub-question validation equation (em_validation_sq)=== <!--T:219--> <!--T:220--> <div class="simplebox">Note: This feat...")
 
m (Text replacement - " enclose="div"" to "")
 
(11 intermediate revisions by 4 users not shown)
Line 5: Line 5:


===Sub-question validation equation (em_validation_sq)=== <!--T:219-->
===Sub-question validation equation (em_validation_sq)=== <!--T:219-->
<!--T:220-->
<div class="simplebox">Note: This features is available starting in version 1.92</div>


<!--T:221-->
<!--T:221-->
Line 13: Line 10:


<!--T:222-->
<!--T:222-->
This is an equation that is used to validate each sub-question (text field) individually.  Any text field that does not pass these validation conditions will have its background color turned pink (using the .em_sq_fn_validation CSS style) to highlight the error.  Note that this is available in addition to the regular expression-based validation option.
This is an equation that is used to validate each subquestion (text field) individually.  Any text field that does not pass these validation conditions will have its background color turned pink (using the .em_sq_fn_validation CSS style) to highlight the error.  Note that this is available in addition to the regular expression-based validation option.


<!--T:223-->
<!--T:223-->
'''Valid values'''
'''Valid values'''
*Any equation, using [[Expression Manager|Expression Manager]] syntax, without surrounding curly braces.
 
<!--T:230-->
Any equation that makes use of the [[ExpressionScript - Presentation|ExpressionScript]] syntax, without surrounding curly braces.


<!--T:224-->
<!--T:224-->
'''Examples'''
'''Examples'''


<!--T:225-->
<!--T:232-->
Say you have a multiple short text question and you want to collect email addresses.  You could use the regular expression validator to make sure the email address has proper syntax, but that doesn't guarantee that the domain name exists.  You could add a function to [[Expression Manager|Expression Manager]] called ''validateEmail()'' which uses DNS lookup service to validate the existence of the domain.
For example, if you want to allow only numbers that are a multiple of 3 as answers, the equation would be:
 
<!--T:226-->
As another example, say you only want to allow numbers that are a multiple of 3, the equation would be:


<!--T:227-->
<!--T:227-->
<syntaxhighlight lang="php" enclose="div">(this / 3) == floor(this/3)</syntaxhighlight>
<syntaxhighlight lang="php">(this / 3) == floor(this/3)</syntaxhighlight>


<!--T:228-->
<!--T:228-->
The reserved variable ''this'' is automatically replaced by a reference to the active text entry cell.
The reserved variable [[ExpressionScript - Presentation#The_reserved_.27this.27.2C_.27self.27.2C_and_.27that.27_variables|''this'']] is automatically replaced by a reference to the active text entry cell.


<!--T:229-->
</onlyinclude>
</onlyinclude>
<!--T:231-->
[[Category:Question Settings]][[Category:Question Logic Options]]


</translate>
</translate>

Latest revision as of 15:01, 16 February 2022


Sub-question validation equation (em_validation_sq)

Description

This is an equation that is used to validate each subquestion (text field) individually. Any text field that does not pass these validation conditions will have its background color turned pink (using the .em_sq_fn_validation CSS style) to highlight the error. Note that this is available in addition to the regular expression-based validation option.

Valid values

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

Examples

For example, if you want to allow only numbers that are a multiple of 3 as answers, the equation would be:

(this / 3) == floor(this/3)

The reserved variable this is automatically replaced by a reference to the active text entry cell.