Check out the LimeSurvey source code on GitHub!

Minimum year > Today

More
6 years 4 weeks ago #55814 by waitz
I am trying to find a regular expression for the date picker, so that 'Today' is the minimum date. Which I haven't found... Is it possible to use the Advanced Settings -> Minimum year to be greater than 'Today'?

Version 1.91+ Build 11232 | PHP 5.3.9 | MySQL 5.1.56 |

Please Log in to join the conversation.

More
6 years 4 weeks ago #55826 by tpartner
You can dynamically set the minimum date after page load. Have a look at the jQery UI datepicker options - jqueryui.com/demos/datepicker/#option-minDate

Cheers,
Tony Partner

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

Please Log in to join the conversation.

More
6 years 3 weeks ago #55980 by waitz
I looked at it, but I'm not sure how to include jquery in a question type. Are there no regular expressions that can define a date to be no earlier than 'today'?

Version 1.91+ Build 11232 | PHP 5.3.9 | MySQL 5.1.56 |

Please Log in to join the conversation.

More
6 years 3 weeks ago #55988 by tpartner
No, I don't think you can do this with regular expressions, you'll need to use JavaScript.

Set up your survey to use JavaScript and place the following script in the source of the date question. Replace "QQ" (line 5) with the ID of the date question.
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		var qID = QQ;
 
		$('#question'+qID+' .popupdate').datepicker( 'option', 'minDate', new Date() );
 
	});
 
</script>

Cheers,
Tony Partner

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

Please Log in to join the conversation.

More
6 years 3 weeks ago #55990 by waitz
Great, thanks. Works like a charm :)

Version 1.91+ Build 11232 | PHP 5.3.9 | MySQL 5.1.56 |

Please Log in to join the conversation.

More
6 years 3 weeks ago #56002 by Mazi
Simple but useful solution. Can you add it to the workarounds?


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

More
6 years 3 weeks ago #56004 by waitz

Mazi wrote: Simple but useful solution. Can you add it to the workarounds?

Not sure if I understand... Is there a limesurvey forum area you want me to add it to, or...?

Version 1.91+ Build 11232 | PHP 5.3.9 | MySQL 5.1.56 |

Please Log in to join the conversation.

More
6 years 3 weeks ago #56007 by tpartner
I'll add it tonight.

Cheers,
Tony Partner

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

Please Log in to join the conversation.

More
6 years 3 weeks ago #56102 by waitz
When Tony's script below can define a date to be not earlier than today, and it refers to a question id, it should be possible to set a rule that the date picker has to be later, or the same, than the date in a previous question in the same question group, no?

tpartner wrote: (...) Set up your survey to use JavaScript and place the following script in the source of the date question. Replace "QQ" (line 5) with the ID of the date question.

<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		var qID = QQ;
 
		$('#question'+qID+' .popupdate').datepicker( 'option', 'minDate', new Date() );
 
	});
 
</script>

This is getting more and more fun ;)

Version 1.91+ Build 11232 | PHP 5.3.9 | MySQL 5.1.56 |

Please Log in to join the conversation.

More
6 years 3 weeks ago #56124 by DenisChenu
Hello,

Maybe you can use docs.jquery.com/UI/Datepicker#option-defaultDate option, with combination with docs.jquery.com/UI/Datepicker/parseDate .

It's just idea :)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).

Please Log in to join the conversation.

More
6 years 3 weeks ago #56172 by tpartner
Yeah, you should be able to put a listener on a first date question to control the behavour of a second date question but you'll need to consider how to handle things like what to do if a respondent returns to Q1 and changes the date to something later than Q2. The script would also be dependent on the date format.

Cheers,
Tony Partner

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

Please Log in to join the conversation.

More
6 years 3 weeks ago #56187 by waitz
Yes, I thought it might be a bit more complicated than what I actually gain. What I have now is the most important, and I have to deal with the fact that a date picker in a previous question group, is also affected by this script for some reason. And it shouldn't

Version 1.91+ Build 11232 | PHP 5.3.9 | MySQL 5.1.56 |

Please Log in to join the conversation.

More
6 years 3 weeks ago #56193 by tpartner
It should not affect any other date pickers if you use the question ID in the selector.


Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:

Please Log in to join the conversation.

More
6 years 3 weeks ago #56194 by waitz

tpartner wrote: It should not affect any other date pickers if you use the question ID in the selector.

Ahh, and now comes the green question: In which question..? Together with the script I put in earlier (and where?)? or in the previous date picker question?

Or do I add it to the calendar selector code itself?
:blush:

Version 1.91+ Build 11232 | PHP 5.3.9 | MySQL 5.1.56 |

Please Log in to join the conversation.

More
6 years 3 weeks ago #56195 by tpartner
Placing my script inthe source of the date question should only affect that question (providing the ID is correct).

Cheers,
Tony Partner

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

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form