$(function() { $.datepicker.setDefaults($.datepicker.regional["ja"]); //土日を選択した場合は時間帯選択の「18時以降(平日のみ)」を非表示にする function doSomething() { if($(this).hasClass('day1')){ $('select[name="date-hope1-time"]').prop("selectedIndex", 0); var date1 = $('.day1').datepicker('getDate'); var day1 = date1.getDay(); // if (day1 == 6 || day1 == 0) { // $(".date-hope1-time select option:last-child").prop('disabled', true); // } // else{ // $(".date-hope1-time select option:last-child").prop('disabled', false); // } } if($(this).hasClass('day2')){ $('select[name="date-hope2-time"]').prop("selectedIndex", 0); var date2 = $('.day2').datepicker('getDate'); var day2 = date2.getDay(); // if (day2 == 6 || day2 == 0) { // $(".date-hope2-time select option:last-child").prop('disabled', true); // } // else{ // $(".date-hope2-time select option:last-child").prop('disabled', false); // } } if($(this).hasClass('day3')){ $('select[name="date-hope3-time"]').prop("selectedIndex", 0); var date3 = $('.day3').datepicker('getDate'); var day3 = date3.getDay(); // if (day3 == 6 || day3 == 0) { // $(".date-hope3-time select option:last-child").prop('disabled', true); // } // else{ // $(".date-hope3-time select option:last-child").prop('disabled', false); // } } } var numberOfMonths; if (window.matchMedia && window.matchMedia('(max-device-width: 640px)').matches) { // smartphone numberOfMonths = 1; } else { // pc numberOfMonths = 2; } $(".date_hope").datepicker( { numberOfMonths: numberOfMonths, autoSize: true,//テキストボックスの幅を自動設定 firstDay: 0, // 日曜始まり dateFormat: 'yy/mm/dd', // minDate: '2025/07/03',//上記で判定した翌日・翌々日の日付を指定 minDate: new Date(2025, 08 - 1, 08), // maxDate: '+3m', onSelect: doSomething, beforeShowDay : function(date) {//以下、休業日設定をする日付を記載 var dateFormat = 'yy/mm/dd'; var disableDates = [ "2022/02/11","2022/02/23","2022/03/21" ]; var disableDate = $.datepicker.formatDate(dateFormat, date); return [( disableDates.indexOf(disableDate) == -1 ), "", "診療日"]; } }); $('.date_hope').attr('readonly',true);//スマホでキーボードを表示しない });