Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: Minimum year > Today

Minimum year > Today 5 years 2 weeks ago #55814

  • waitz
  • waitz's Avatar
  • Offline
  • Gold Lime
  • Posts: 171
  • Thank you received: 1
  • Karma: 3
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 |
The administrator has disabled public write access.

Minimum year > Today 5 years 2 weeks ago #55826

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5421
  • Thank you received: 1156
  • Karma: 480
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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Minimum year > Today 5 years 2 weeks ago #55980

  • waitz
  • waitz's Avatar
  • Offline
  • Gold Lime
  • Posts: 171
  • Thank you received: 1
  • Karma: 3
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 |
The administrator has disabled public write access.

Minimum year > Today 5 years 2 weeks ago #55988

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5421
  • Thank you received: 1156
  • Karma: 480
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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

[SOLVED] Re: Minimum year > Today 5 years 2 weeks ago #55990

  • waitz
  • waitz's Avatar
  • Offline
  • Gold Lime
  • Posts: 171
  • Thank you received: 1
  • Karma: 3
Great, thanks. Works like a charm :)
Version 1.91+ Build 11232 | PHP 5.3.9 | MySQL 5.1.56 |
The administrator has disabled public write access.

[SOLVED] Re: Minimum year > Today 5 years 1 week ago #56002

  • Mazi
  • Mazi's Avatar
  • Online
  • LimeSurvey Team
  • Posts: 5843
  • Thank you received: 348
  • Karma: 261
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)limesurvey.org'"
The administrator has disabled public write access.

[SOLVED] Re: Minimum year > Today 5 years 1 week ago #56004

  • waitz
  • waitz's Avatar
  • Offline
  • Gold Lime
  • Posts: 171
  • Thank you received: 1
  • Karma: 3
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 |
The administrator has disabled public write access.

[SOLVED] Re: Minimum year > Today 5 years 1 week ago #56007

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5421
  • Thank you received: 1156
  • Karma: 480
I'll add it tonight.
Cheers,
Tony Partner

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

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Minimum year > Today 5 years 1 week ago #56102

  • waitz
  • waitz's Avatar
  • Offline
  • Gold Lime
  • Posts: 171
  • Thank you received: 1
  • Karma: 3
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 |
The administrator has disabled public write access.

Minimum year > Today 5 years 1 week ago #56124

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • Moderator Lime
  • Posts: 8249
  • Thank you received: 1126
  • Karma: 336
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 :)
The administrator has disabled public write access.

Minimum year > Today 5 years 1 week ago #56172

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5421
  • Thank you received: 1156
  • Karma: 480
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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Minimum year > Today 5 years 1 week ago #56187

  • waitz
  • waitz's Avatar
  • Offline
  • Gold Lime
  • Posts: 171
  • Thank you received: 1
  • Karma: 3
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 |
The administrator has disabled public write access.

Minimum year > Today 5 years 1 week ago #56193

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5421
  • Thank you received: 1156
  • Karma: 480
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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Minimum year > Today 5 years 1 week ago #56194

  • waitz
  • waitz's Avatar
  • Offline
  • Gold Lime
  • Posts: 171
  • Thank you received: 1
  • Karma: 3
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 |
The administrator has disabled public write access.

Minimum year > Today 5 years 1 week ago #56195

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5421
  • Thank you received: 1156
  • Karma: 480
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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Moderators: ITEd
Time to create page: 0.346 seconds