- 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>
$(document).ready(function() {
var date = new Date();
var tim = date.getTime();
var d = new Date(tim+(60*60*24*1000)*2);
var years = d.getFullYear();
var years2 = years+1;
var chaine = d.getFullYear() + "-";
var mois = (d.getMonth()+1) ;
mois = mois.toString();
if(mois.length == 1)
mois = '0'+mois;
var day = d.getDate();
day = day.toString();
if(day.length == 1)
day = '0'+day;
chaine += mois + "-"+day;
var thisQuestion = $('#question{QID}');
$('input[type="text"]', thisQuestion).datetimepicker({
format : 'DD/MM/YYYY',
daysOfWeekDisabled : [0,6],
disabledDates: [years+'-01-01',years+'-05-01',years+'-05-08',years+'-07-14',years+'-08-15',years+'-11-01',years+'-11-11',years+'-12-25',years2+'-01-01',years2+'-05-01',years2+'-05-08',years2+'-07-14',years2+'-08-15',years2+'-11-01',years2+'-11-11',years2+'-12-25'],
minDate : chaine
});
});