- Posts: 3
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Validate Subquestions?
- iwebkat
- Topic Author
- Offline
- New Member
Less
More
11 years 10 months ago #82428
by iwebkat
Validate Subquestions? was created by iwebkat
I have used multiple short answers for a section including gathering name, email, phone, etc. Is there a way to add validation to these individual subquestions? I know regular expressions can be used for email addresses, zip codes, and phone numbers, but I haven't found a way to implement this.
I have been searching the manual, and have found the regular expression codes, but cannot find where exactly to put them to make them work.
Any pointers would be greatly appreciated. Thanks in advance!
I have been searching the manual, and have found the regular expression codes, but cannot find where exactly to put them to make them work.
Any pointers would be greatly appreciated. Thanks in advance!
The topic has been locked.
- KRav
- Offline
- New Member
Less
More
- Posts: 5
- Thank you received: 1
11 years 10 months ago #82431
by KRav
research on BLOGS - Professional LimeSurvey support
Consultant - Templates - Training - JQuery magic - Support - Coding - Survey creation and more..
Contact
Professional LimeSurvey support
info@researchonBLOGS.de
Replied by KRav on topic Validate Subquestions?
as far as I know it's not possible. I would use single questions.
research on BLOGS - Professional LimeSurvey support
Consultant - Templates - Training - JQuery magic - Support - Coding - Survey creation and more..
Contact
Professional LimeSurvey support
info@researchonBLOGS.de
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11645
- Thank you received: 2739
11 years 10 months ago #82433
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Validate Subquestions?
I read somewhere, that this option exists in the newest version, but I can't really tell how this works.
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The topic has been locked.
- iwebkat
- Topic Author
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 0
11 years 10 months ago #82434
by iwebkat
Replied by iwebkat on topic Validate Subquestions?
Thanks...if I can't figure out the sub-question route then I'll definite do this. It's nice to know it just isn't there.
The topic has been locked.
- iwebkat
- Topic Author
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 0
11 years 10 months ago #82435
by iwebkat
Replied by iwebkat on topic Validate Subquestions?
I just upgraded to the newest version, but I can't see where to validate subquestions. If you have any idea where to point me, I'll be happy to try.
Thanks!
Thanks!
The topic has been locked.
- TMSWhite
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 44
- Thank you received: 15
11 years 10 months ago - 11 years 10 months ago #82436
by TMSWhite
If you depend upon LimeSurvey or the support team, please give generously to our 2012 fundraiser .
Replied by TMSWhite on topic Validate Subquestions?
The optimal way to validate sub-questions has not been implemented. Ideally, there would be a regex validation equation per sub-question so you could have different ones for each part of a multiple-short text. That doesn't exist yet (and probably won't for quite a while unless you know of volunteers with time to implement it).
However, you can fake it using the Whole question validation and Tip for whole question validation options.
Here is a working example.
Say your question is "q1", and your sub-questions are "name", "email", and "phone", you could set the Whole question validation to:
This will ensure that the user enters a valid email and phone number (in this case, a non-answer is also accepted via is_empty()).
Then, to tailor the validation message, you would use this for the Tip for whole question validation .
As you can see, you are using the exact same validation expression for q1_email and q1_phone, you're just surrounding it with:
And here are some screen shots:
However, you can fake it using the Whole question validation and Tip for whole question validation options.
Here is a working example.
Say your question is "q1", and your sub-questions are "name", "email", and "phone", you could set the Whole question validation to:
Code:
(is_empty(q1_email) or regexMatch('/(\w[-._\w]*\w@\w[-._\w]*\w\.\w{2,3})/', q1_email)) and (is_empty(q1_phone) or regexMatch('/^(?:\([2-9]\d{2}\)\ ?|[2-9]\d{2}(?:\-?|\ ?))[2-9]\d{2}[- ]?\d{4}$/', q1_phone))
This will ensure that the user enters a valid email and phone number (in this case, a non-answer is also accepted via is_empty()).
Then, to tailor the validation message, you would use this for the Tip for whole question validation .
Code:
{if((is_empty(q1_email) or regexMatch('/(\w[-._\w]*\w@\w[-._\w]*\w\.\w{2,3})/', q1_email)), '', 'Please enter a valid email address.<br />')} {if((is_empty(q1_phone) or regexMatch('/^(?:\([2-9]\d{2}\)\ ?|[2-9]\d{2}(?:\-?|\ ?))[2-9]\d{2}[- ]?\d{4}$/', q1_phone)), '', 'Please enter a valid phone number.')}
As you can see, you are using the exact same validation expression for q1_email and q1_phone, you're just surrounding it with:
Code:
{if(validation_expression,'','Please enter a valid ....')}
And here are some screen shots:
If you depend upon LimeSurvey or the support team, please give generously to our 2012 fundraiser .
- Expression Manager (EM):
Documentation
|
Sample Surveys
|
How Tos
|
Show Logic File
|
Upgrading to 1.92+ - Excel Style for Survey Structure Import/Export
Attachments:
Last edit: 11 years 10 months ago by TMSWhite.
The topic has been locked.
- janwillem64
- Offline
- New Member
Less
More
- Posts: 1
- Thank you received: 0
11 years 10 months ago #82491
by janwillem64
Replied by janwillem64 on topic Validate Subquestions?
Hello TMSWhite, Got it!! For the others with same issue. Go to question. Go to advanced settings. Fill in the validation in 'Question validation equation' and the tip in 'Question validation tip'. The tip validates the same and shows the error message. q1 is your question code and email is sub question code. Good luck. And thanks TMSWhite.
The topic has been locked.
- Mazi
- Offline
- Official LimeSurvey Partner
11 years 10 months ago #82492
by Mazi
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
Replied by Mazi on topic Validate Subquestions?
Please add a note to the manual as well so other benefit from the findings, too.janwillem64 wrote: Hello TMSWhite, Got it!! For the others with same issue. Go to question. Go to advanced settings. Fill in the validation in 'Question validation equation' and the tip in 'Question validation tip'. The tip validates the same and shows the error message. q1 is your question code and email is sub question code. Good luck. And thanks TMSWhite.
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The topic has been locked.
- TMSWhite
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 44
- Thank you received: 15
11 years 10 months ago #82505
by TMSWhite
If you depend upon LimeSurvey or the support team, please give generously to our 2012 fundraiser .
Replied by TMSWhite on topic Validate Subquestions?
I've updated the manual
here
.
If you depend upon LimeSurvey or the support team, please give generously to our 2012 fundraiser .
- Expression Manager (EM):
Documentation
|
Sample Surveys
|
How Tos
|
Show Logic File
|
Upgrading to 1.92+ - Excel Style for Survey Structure Import/Export
The topic has been locked.
- debianese
- Offline
- New Member
Less
More
- Posts: 1
- Thank you received: 0
11 years 8 months ago #84340
by debianese
Replied by debianese on topic Validate Subquestions?
Thanks! This topic has helped me a lot!
But I have another question: How can you localize the error message?
I have to create a survey in german and english. The error message should be in the selected language!
But I have another question: How can you localize the error message?
I have to create a survey in german and english. The error message should be in the selected language!
The topic has been locked.
- TMSWhite
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 44
- Thank you received: 15
11 years 8 months ago - 11 years 8 months ago #84342
by TMSWhite
If you depend upon LimeSurvey or the support team, please give generously to our 2012 fundraiser .
Replied by TMSWhite on topic Validate Subquestions?
For 1.92, you can do this:
For 2.0, I'd recommend making this field one of those that can be translated into multiple languages via the quick translation feature.
Code:
{if(validation_expression,'',if(LANG=='en','Please enter a valid ....','Bitte antworten ...'))}
For 2.0, I'd recommend making this field one of those that can be translated into multiple languages via the quick translation feature.
If you depend upon LimeSurvey or the support team, please give generously to our 2012 fundraiser .
- Expression Manager (EM):
Documentation
|
Sample Surveys
|
How Tos
|
Show Logic File
|
Upgrading to 1.92+ - Excel Style for Survey Structure Import/Export
Last edit: 11 years 8 months ago by TMSWhite.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13633
- Thank you received: 2491
11 years 8 months ago - 11 years 8 months ago #84367
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Validate Subquestions?
Hello,
Can use pseudo class lang too in template.css:
And in template.css
Denis
Can use pseudo class lang too in template.css:
Code:
<span lang="en">'Please enter </span><span lang="de">Bitte antworten</span>
And in template.css
Code:
:lang(en) :lang(de){display:none} :lang(de) :lang(en){display:none}
Denis
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Last edit: 11 years 8 months ago by DenisChenu. Reason: typo and code
The topic has been locked.