Check out the LimeSurvey source code on GitHub!

date question type

More
5 years 4 months ago #66886 by Eddie_V
it didn't redirect me corretly but I found what you ment.

one question tho, what would happen if a user in limesurvey would set a min date in the attributes, would that still override the date I set in the template.js?

I dont have the source code here at home, so I cannot do a quick test, but if it still works that way I will try/implement your suggestion.

Please Log in to join the conversation.

More
5 years 4 months ago - 5 years 4 months ago #66933 by tpartner
Well, it turns out that my fix does take precedence over the advanced settings so we need a test to see if the admin set those.

This script will set a new minimum and maximum year for all date questions that do not have the "Minimum year" or "Maximum year" advanced settings changed.
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
			var newMinYear = 1920;
			var newMaxYear = 2030;
 
			$('.date').each(function(){
 
				var qYearRange = $('input[id^="dateyearrange"]', this).val();
 
				if(qYearRange == '1980:2020') {
					$('.popupdate', this).datepicker( 'option', "yearRange", ''+newMinYear+':'+newMaxYear+'' );
					$('.popupdate', this).datepicker( 'option', 'minDate', new Date(newMinYear, 1-1, 1) );
					$('.popupdate', this).datepicker( 'option', 'maxDate', new Date(newMaxYear, 1-1, 1) );
				}
			});
	});
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last Edit: 5 years 4 months ago by tpartner.

Please Log in to join the conversation.

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