- Posts: 2811
- Karma: 254
- Thank you received: 227
- English support forums
- Installation & update issues
- How to add regular express validation in short text input field?
How to add regular express validation in short text input field?
We should really put that on our list (If I remember correctly, you already have such a list?).
TMSWhite wrote: the preg field is question specific, so in the future, we could allow for sub-question-level validation - e.g. a different regex for each sub-question. Right now, that isn't supported. However, it would really only require a new GUI to enter sub-question-level validation (and relevance, since that is also often desired), plus minor changes to EM.
Because mostly, users use the multiple short text to ask for address or contact data and it really makes sense to have a validation for each field.
If we were to augment what we can do with sub-questions, I'd propose adding the following options to each sub-question. Using your example of collecting address information as multiple short text:
(1) relevance - since different sub-fields are relevant for different countries
(2) validation - since different field-types have different validation requirements
(a) we might even want conditional validation - if you wanted to have one field for postal code, but validate it differently depending upon the addresses' country.
(3) mandatory - a different set of fields is required for each type of address
(a) we might also want to consider conditional mandatory
Depending on that effort we should maybe start small and then extend that feature for Limesurvey 2.x?
My list of priorities would read:
1. Relevance/conditions for sub-questions
2. Mandatory setting for sub-questions
3. Validations for sub-questions
4. Conditional mandatory for sub-questions
5. Conditional validation for sub-questions
perhaps we can use a "Show advanced subquestion settings" link like it is used in the "Show advanced settings" in the questions.
Mit freundlichen Grüßen/Best regards,
If so, give me a step of UI or hints.
Can you give an example of why you would want to compose different regex validations using those token attributes?
All of the advanced question attributes are parsed by EM, except for the regular expression validation in the core validation option. So if you want to specify min/max answers, or min/max numerical value, you can use those options.
If you really need to do dynamic regular expression validation, then you could use new the em_validation_q advanced question option. Say your regular expression pattern is composed of two attributes, you could set the em_validation_q equation to:
where this will end up referring to the current variable name.