limit period of time in date field

More
5 years 5 months ago #81529 by MPIDR
MPIDR created the topic: limit period of time in date field
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

Please Log in to join the conversation.

More
5 years 5 months ago #81559 by KRav
KRav replied the topic: Aw: limit period of time in date field
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.

Please Log in to join the conversation.

More
5 years 5 months ago #81573 by tpartner
tpartner replied the topic: limit period of time in date field
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.

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!