var elm = document.getElementById("snow-monkey-form-122"); if (elm != null) { initializeDatepicker(); } // MutationObserver var observer; if (elm != null) { observer = new MutationObserver(function (mutations, observer) { initializeDatepicker(); }); var config = { attributes: true, }; observer.observe(elm, config); } // datepicker function initializeDatepicker() { $(function () { const $target = $(".js-datepicker"); const dateFormat = 'yy/mm/dd'; const disableDates = ["2024/01/01","2024/01/02","2024/01/03","2024/01/04","2024/01/10","2024/01/15","2024/01/16","2024/01/23","2024/01/28","2024/01/29","2024/02/06","2024/02/07","2024/02/08","2024/02/09","2024/02/10","2024/02/11","2024/02/12","2024/02/19","2024/02/22","2024/02/28","2024/03/04","2024/03/10","2024/03/11","2024/03/14","2024/03/19","2024/03/26","2024/03/27","2024/03/31","2024/04/01","2024/04/08","2024/04/09","2024/04/15","2024/04/18","2024/04/23","2024/04/24","2024/05/01","2024/05/02","2024/05/03","2024/05/05","2024/05/07","2024/05/15","2024/05/23","2024/05/26","2024/05/27","2024/05/31","2024/06/05","2024/06/10","2024/06/13","2024/06/16","2024/06/17","2024/06/18","2024/06/26","2024/06/28",""]; const enableDates = []; $target.attr("autocomplete", "off"); $target.attr('readonly', 'readonly'); $target.datepicker({ dateFormat: dateFormat, firstDay: 1, minDate: '+1d', maxDate: '+3m', beforeShowDay : function(date) { const disableDate = $.datepicker.formatDate(dateFormat, date); const enableDate = $.datepicker.formatDate(dateFormat, date); if (disableDates.indexOf(disableDate) !== -1) { if (enableDates.indexOf(enableDate) == -1) { return [false, 'ui-state-disabled']; } } if(date.getDay() == 0) { return [true, 'class-sunday']; } if(date.getDay() == 6) { return [true, 'class-saturday']; } return [true, '']; }, }); }); }