- Posts: 35
- Thank you received: 1
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, 'News Years day'], [2, 16, 'Family Day'], [4, 3, 'Good Friday'], [5, 18, 'Victoria Day'], [7, 1, 'Canada Day'], [9, 7, 'Labour Day'], [10, 12, 'Thanksgiving'], [12, 25, 'Christmas'], [12, 26, 'Boxing Day'] ]; // 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 == 6) { returnedArr = [false, 'holiday', value[2]+', cannot choose a weekend day']; // Weekend holiday } else { returnedArr = [true, 'holiday', value[2]]; // Weekday holiday } return false; // Exit the loop } else if (thisDay == 0 || thisDay == 6) { returnedArr = [false, '', 'Cannot choose a weekend day']; // Weekend day } }); return returnedArr; } // Apply the new "beforeShowDay" option $('input[type="text"]', thisQuestion).datepicker('option', 'beforeShowDay', showHolidaysDisableWeekends); }); </script>
.ui-datepicker-calendar td.holiday a, .ui-datepicker-calendar td.holiday span { background: none pink !important; }
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify this question var thisQuestion = $('#question{QID}'); // No weekends $('input[type="text"]', thisQuestion).datepicker('option', 'beforeShowDay', $.datepicker.noWeekends); }); </script>
When I open the survey the calendar shows up, and not only one cliks on the button with the 3 dots of the date question.
$('input[type="text"]', thisQuestion).datepicker('option', 'beforeShowDay', showHolidaysDisableWeekends).datepicker( "show" );
$('input[type="text"]', thisQuestion).datepicker('option', 'beforeShowDay', showHolidaysDisableWeekends);
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ // Disable days of week $('#answer{SGQ}_datetimepicker').data('DateTimePicker').daysOfWeekDisabled([0,1,5,6]); }); </script>