Actions

QS

Em validation sq/en: Difference between revisions

From LimeSurvey Manual

(Importing a new version from external source)
(Updating to match new version of source page)
Line 3: Line 3:


===Sub-question validation equation (em_validation_sq)===
===Sub-question validation equation (em_validation_sq)===
{{FeatureStarting|v=1.92}}


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


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.


'''Valid values'''
'''Valid values'''


Any equation, using [[Expression Manager|Expression Manager]] syntax, without surrounding curly braces.
Any equation that makes use of the [[Expression Manager]] syntax, without surrounding curly braces.


'''Examples'''
'''Examples'''


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.
For example, if you want to allow only numbers that are a multiple of 3 as answers, the equation would be:
 
As another example, say you only want to allow numbers that are a multiple of 3, the equation would be:


<syntaxhighlight lang="php" enclose="div">(this / 3) == floor(this/3)</syntaxhighlight>
<syntaxhighlight lang="php" enclose="div">(this / 3) == floor(this/3)</syntaxhighlight>
Line 26: Line 22:
</onlyinclude>
</onlyinclude>


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

Revision as of 15:35, 31 March 2018


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 Expression Manager 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.