- Posts: 107
- Thank you received: 4
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Validate the "Other" field
- Matadeleo
- Topic Author
- Offline
- Premium Member
Less
More
5 years 9 months ago - 5 years 9 months ago #171163
by Matadeleo
Validate the "Other" field was created by Matadeleo
Hi, I'm wondering if it's possible to validate my "other" box -
Here is the code I would use for this if I were validating a question or subquestion:
Question validation equation
Question validation tip
In this case, I believe instead of targeting self - we would need to target something like "Q1_other.shown" - but I think this solution would need some kind of JavaScript solution?
Here is the code I would use for this if I were validating a question or subquestion:
Question validation equation
Code:
regexMatch('/^(\w[-._+\w]*\w@\w[-._\w]*\w\.\w{2,3})$/', self)
Question validation tip
Code:
{if(regexMatch('/^(\w[-._+\w]*\w@\w[-._\w]*\w\.\w{2,3})$/',self),"Email validated","Please enter a valid email address")}
In this case, I believe instead of targeting self - we would need to target something like "Q1_other.shown" - but I think this solution would need some kind of JavaScript solution?
Attachments:
Last edit: 5 years 9 months ago by Matadeleo.
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12923
- Thank you received: 3977
5 years 9 months ago - 5 years 9 months ago #171166
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Validate the "Other" field
Hi,
no JS needed.
Activate your survey, enter the data and submit.
Look at the answers and you will see how this "open ends" are saved. (as "Q1_other")
Now you can include this in your "regexMatch('/^(\w[-._+\w]*\w@\w[-._\w]*\w\.\w{2,3})$/', Q1_other)
and add the condition
that !is_empty(Q1_other)
or Q1=="-oth-"
Example:
equation:
(regexMatch('/^(\w[-._+\w]*\w@\w[-._\w]*\w\.\w{2,3})$/', Q1_other)) and (!is_empty(Q1_other))
Tip:
{if((!regexMatch('/^(\w[-._+\w]*\w@\w[-._\w]*\w\.\w{2,3})$/', Q1_other)) and (!is_empty(Q1_other)),"Please, corrrect Email","")}
Joffm
no JS needed.
Activate your survey, enter the data and submit.
Look at the answers and you will see how this "open ends" are saved. (as "Q1_other")
Now you can include this in your "regexMatch('/^(\w[-._+\w]*\w@\w[-._\w]*\w\.\w{2,3})$/', Q1_other)
and add the condition
that !is_empty(Q1_other)
or Q1=="-oth-"
Example:
equation:
(regexMatch('/^(\w[-._+\w]*\w@\w[-._\w]*\w\.\w{2,3})$/', Q1_other)) and (!is_empty(Q1_other))
Tip:
{if((!regexMatch('/^(\w[-._+\w]*\w@\w[-._\w]*\w\.\w{2,3})$/', Q1_other)) and (!is_empty(Q1_other)),"Please, corrrect Email","")}
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 5 years 9 months ago by Joffm.
The topic has been locked.
- Matadeleo
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 107
- Thank you received: 4
5 years 9 months ago - 5 years 9 months ago #171172
by Matadeleo
Replied by Matadeleo on topic Validate the "Other" field
Attachments:
Last edit: 5 years 9 months ago by Matadeleo.
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12923
- Thank you received: 3977
5 years 9 months ago #171174
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Validate the "Other" field
You see, what is missing?
regexMatch('/^(\w[-._+\w]*\w@\w[-._\w]*\w\.\w{2,3})$/', Q1_other)) and (!is_empty(Q1_other)) or (Q1==1)
regexMatch('/^(\w[-._+\w]*\w@\w[-._\w]*\w\.\w{2,3})$/', Q1_other)) and (!is_empty(Q1_other)) or (Q1==1)
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: Matadeleo
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3593
5 years 9 months ago #171182
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Validate the "Other" field
If using the default answer codes, it might be:
Code:
regexMatch('/^(\w[-._+\w]*\w@\w[-._\w]*\w\.\w{2,3})$/', Q1_other)) AND (!is_empty(Q1_other)) OR (Q1=="A1")
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: Matadeleo
The topic has been locked.
- Matadeleo
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 107
- Thank you received: 4
5 years 9 months ago #171190
by Matadeleo
Replied by Matadeleo on topic Validate the "Other" field
Thanks for the assistance guys, I'm happy with how it's working now
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13643
- Thank you received: 2491
5 years 9 months ago #171223
by DenisChenu
regexMatch('/^(\w[-._+\w]*\w@\w[-._\w]*\w\.\w{2,63})$/', Q1_other))
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 the "Other" field
Since there are .social , .anything etc domain now, need to be updated totpartner wrote: If using the default answer codes, it might be:
Code:regexMatch('/^(\w[-._+\w]*\w@\w[-._\w]*\w\.\w{2,3})$/', Q1_other)) AND (!is_empty(Q1_other)) OR (Q1=="A1")
regexMatch('/^(\w[-._+\w]*\w@\w[-._\w]*\w\.\w{2,63})$/', Q1_other))
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.
The topic has been locked.