- Posts: 9
- Thank you received: 2
Ask the community, share ideas, and connect with other LimeSurvey users!
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
// Identify this question
var thisQuestion = $('#question{QID}');
// The holidays - format: [month, date, description]
holidays = [
[1, 1, 'Nouvel an'], [12, 25, 'Noel']
];
// A function to show holidays and disable weekend days in a datepicker
function showHolidaysDisableWeekends(date) {
var thisMonth = date.getMonth();
var thisDate = date.getDate();
var thisDay = date.getDay();
var returnedArr = [true, '']; // Normal day
// Loop through the holidays
$(holidays).each(function(i, value) {
if (thisMonth == value[0] - 1 && thisDate == value[1]) {
if(thisDay == 0 || thisDay == 2 || thisDay == 3 || thisDay == 4 || thisDay == 5 || thisDay == 6) {
returnedArr = [false, 'holiday', value[2]+', choisir un lundi']; // Weekend holiday
}
else {
returnedArr = [true, 'holiday', value[2]]; // Weekday holiday
}
return false; // Exit the loop
}
else if (thisDay == 0 || thisDay == 2 || thisDay == 3 || thisDay == 4 || thisDay == 5 || thisDay == 6) {
returnedArr = [false, '', 'Choisir un lundi']; // Weekend day
}
});
return returnedArr;
}
// Apply the new "beforeShowDay" option
$('input[type="text"]', thisQuestion).datepicker('option', 'beforeShowDay', showHolidaysDisableWeekends);
});
</script>