Welcome, Guest
Username: Password: Remember me

TOPIC: limit period of time in date field

limit period of time in date field 2 years 3 months ago #81529

  • MPIDR
  • MPIDR's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 17
  • Karma: 0
I have a survey with a date field and would like to limit the period of time that can be chosen. Can this be done?

In the advanced settings, only the minimum and maximum year can be set. However, I'd like to limit the selection to something like August 13th until August 25th.

Regards
MPIDR
The administrator has disabled public write access.

Aw: limit period of time in date field 2 years 3 months ago #81559

  • ResearchOnBlogs
  • ResearchOnBlogs's Avatar
  • OFFLINE
  • Gold Lime
  • Posts: 184
  • Thank you received: 16
  • Karma: 8
Hi MPIDR,

as far as I know is the datepicker of the datefiled jquery ui. In order to that I would try to set a limit with jquery:
jqueryui.com/demos/datepicker/#min-max

Cheers Kai

research on BLOGS - Professional LimeSurvey support
Consultant - Templates - Training - JQuery magic - Support - Coding - Survey creation and more..

Contact
Professional LimeSurvey support
This email address is being protected from spambots. You need JavaScript enabled to view it.
The administrator has disabled public write access.

Re: limit period of time in date field 2 years 3 months ago #81573

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4192
  • Thank you received: 788
  • Karma: 359
More specifically...

1) Set up your survey to use JavaScript.

2) Add the following script to the source of the date question. Replace "QQ" with the date question ID.

The script resets the max and min date options of the datepicker.
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function () {
 
		$(document).ready(function(){
 
		$('#questionQQ .popupdate').datepicker( 'option', 'minDate', new Date(2012, 8 - 1, 13) );
		$('#questionQQ .popupdate').datepicker( 'option', 'maxDate', new Date(2012, 8 - 1, 25) );
	});
 
</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.
Moderators: ITEd
Time to create page: 0.116 seconds
Donation Image