Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Question date with other field or description

  • SabrinaCasanova
  • SabrinaCasanova's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 8 months ago #171556 by SabrinaCasanova
Question date with other field or description was created by SabrinaCasanova
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
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 8 months ago #171558 by tpartner
Replied by tpartner on 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
The topic has been locked.
  • SabrinaCasanova
  • SabrinaCasanova's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 8 months ago #171559 by SabrinaCasanova
Replied by SabrinaCasanova on 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
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 8 months ago #171561 by tpartner
Replied by tpartner on 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.
The topic has been locked.
  • SabrinaCasanova
  • SabrinaCasanova's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 8 months ago #171562 by SabrinaCasanova
Replied by SabrinaCasanova on 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
The topic has been locked.
  • SabrinaCasanova
  • SabrinaCasanova's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 8 months ago #171564 by SabrinaCasanova
Replied by SabrinaCasanova on topic Question date with other field or description
tpartner any news please
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 8 months ago #171565 by Joffm
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
The topic has been locked.
  • SabrinaCasanova
  • SabrinaCasanova's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 8 months ago #171568 by SabrinaCasanova
Replied by SabrinaCasanova on 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
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 8 months ago - 5 years 8 months ago #171569 by Joffm
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:
stackoverflow.com/questions/15491894/reg...-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 manual.limesurvey.org/Expression_Manager...nager_Sample_Surveys
or in the demo installation demo.limesurvey.org/admin/admin.php

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 5 years 8 months ago by Joffm.
The following user(s) said Thank You: SabrinaCasanova
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 8 months ago #171622 by Joffm
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
The following user(s) said Thank You: DenisChenu, SabrinaCasanova
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose