Question date with other field or description

More
2 months 4 weeks ago #171556 by SabrinaCasanova
SabrinaCasanova created the topic: Question date with other field or description
Hi Team,

I have a question date format i want to add with the calendar or dropdown boxes another text field (to put some description). i can ? if yes how ?
If no, if i create a question with Multiple short text, i can validate only one field for the date format and the other field (text) for the description ?

Thanks

Please Log in or Create an account to join the conversation.

More
2 months 4 weeks ago #171558 by tpartner
tpartner replied the topic: Question date with other field or description
Why not use two questions?

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: DenisChenu

Please Log in or Create an account to join the conversation.

More
2 months 4 weeks ago #171559 by SabrinaCasanova
SabrinaCasanova replied the topic: Question date with other field or description
I want them in the same question, because we can have the description then the date or the opposite; and in the case of two question it will have a switch between previous and next

Please Log in or Create an account to join the conversation.

More
2 months 4 weeks ago #171561 by tpartner
tpartner replied the topic: Question date with other field or description
Run the survey in group-by-group mode and place both questions in the same group.

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in or Create an account to join the conversation.

More
2 months 4 weeks ago #171562 by SabrinaCasanova
SabrinaCasanova replied the topic: Question date with other field or description
I have a long questionnaire and a lot of conditions to show or hide some questions, and it's a hard work to do for each question a group, my only solution and one of the two mentioned above, if it's possible.

Thanks

Please Log in or Create an account to join the conversation.

More
2 months 4 weeks ago #171564 by SabrinaCasanova
SabrinaCasanova replied the topic: Question date with other field or description
tpartner any news please

Please Log in or Create an account to join the conversation.

More
2 months 4 weeks ago #171565 by Joffm
Joffm replied the topic: Question date with other field or description
Hi, Sabrina,

you have a solution. your second idea:
Multiple short text and validate the first subquestion with subquestion validation
regexMatch(']pattern to validate date]', Q1_SQ001)

Joffm


Remember, we all are volunteers. So please do not expect people to be available or online all the time, especially on a saturday at night.
Sometimes you need a little bit of patience.


Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: SabrinaCasanova

Please Log in or Create an account to join the conversation.

More
2 months 4 weeks ago #171568 by SabrinaCasanova
SabrinaCasanova replied the topic: Question date with other field or description
Thank you Joffm,

How i use this validation and where? it will be better if you have a Demo i am beginner

Please Log in or Create an account to join the conversation.

More
2 months 4 weeks ago - 2 months 4 weeks ago #171569 by Joffm
Joffm replied the topic: Question date with other field or description
Hi, Sabrina,
in "Edit questions" / "Logic" you find the "Question validation equation: ", where you enter your validaten equation:

The check "is_empty" is to avoid an error message right at the start.

Underneath there is the field "Question validation tip". Here you give nformation to your respondents.
In this case I used the if-statement to distinguish between a "good" message and the "bad" message".

This validation
regexMatch('/^(19|20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/',Q01_SQ001)

will validate a date format "yyyy-mm-dd"
but NOT check 30th of february, 31st of april, etc.


More about regular expressions regarding dates you might find here:
https://stackoverflow.com/questions/15491894/regex-to-validate-date-format-dd-mm-yyyy#15504877


On the other side I agree to Tony:
Use question groups and put these two questions into one group.
It is not very time consuming to change the structure of your survey.
First create as many new groups as you need.
Just click "add new group", give a title and save. I should say "Less than 10 seconds per group".
And afterwards you drag the questions into the groups by "organizer".

Best regards
Joffm

P.S.
We all were beginners.
So I's davice:
Read the manual,
study the demo surveys, either import them here https://manual.limesurvey.org/Expression_Manager#Expression_Manager_Sample_Surveys
or in the demo installation http://demo.limesurvey.org/admin/admin.php


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Attachments:
Last Edit: 2 months 4 weeks ago by Joffm.

Please Log in or Create an account to join the conversation.

More
2 months 3 weeks ago #171622 by Joffm
Joffm replied the topic: Question date with other field or description
Hi, Sabrina,

an addition, if you do not want to change to the group by group structure.

There is an implemented function "checkdate" which really checks dates (including leap years) instead of just checking the format.
Unfortunately the syntax is checkdate(month,day,year), meaning you have to split the entered value into these three parts. Well, easily done by some function (intval and substr).
As you know the structure of the date (e.g. "yyyy-mm-dd") you can say:

checkdate((intval(substr(Q1_SQ001,5,2)),intval(substr(Q1_SQ001,8,2)),intval(substr(Q1_SQ001,0,4)))
Remember: substr starts counting at "0".

Total validation:
((checkdate(intval(substr(Q01_SQ001, 5, 2)), intval(substr(Q01_SQ001, 8, 2)), intval(substr(Q01_SQ001, 0, 4)))) OR is_empty(Q01_SQ001))


And the tip could be:
{if((checkdate(intval(substr(Q01_SQ001,5,2)),intval(substr(Q01_SQ001,8,2)),intval(substr(Q01_SQ001,0,4))) OR is_empty(Q01_SQ001)) ,"Please enter a date","Please enter a valid date")}

By changing the substr-values you can adapt to other date formats.

Result:






Best regards
Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Attachments:
The following user(s) said Thank You: DenisChenu

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!