0
사용자 선택 JQuery와 날짜 선택기에 따라 일 해제하는 방법 :내가 다음 코드 한
HTML
<p>from</p>
<input type="text" class="spromotion-input-inbody spromotion-input-datepick" id="sproid-bookingcondition-datefrom">
<p>to</p>
<input type="text" class="spromotion-input-inbody spromotion-input-datepick" id="sproid-bookingcondition-dateto">
<p>
select days of the week
</p>
<div>
<div class="spromotion-condition-datepickerbox" id="sproid-bookingcond-aplicabledays">
<label name="promo-type" class="radio-inline spromotion-aplicabledays-checkbx">
<input type="checkbox" value="sunday" name="condition-aplicable-day" checked>S
</label>
<label name="promo-type" class="radio-inline spromotion-aplicabledays-checkbx">
<input type="checkbox" value="monday" name="condition-aplicable-day" checked>M
</label>
<label name="promo-type" class="radio-inline spromotion-aplicabledays-checkbx">
<input type="checkbox" value="tuesday" name="condition-aplicable-day" checked>T
</label>
<label name="promo-type" class="radio-inline spromotion-aplicabledays-checkbx">
<input type="checkbox" value="wednesday" name="condition-aplicable-day" checked>W
</label>
<label name="promo-type" class="radio-inline spromotion-aplicabledays-checkbx">
<input type="checkbox" value="thursday" name="condition-aplicable-day" checked>T
</label>
<label name="promo-type" class="radio-inline spromotion-aplicabledays-checkbx">
<input type="checkbox" value="friday" name="condition-aplicable-day" checked>F
</label>
<label name="promo-type" class="radio-inline spromotion-aplicabledays-checkbx">
<input type="checkbox" value="saturday" name="condition-aplicable-day" checked>S
</label>
</div>
</div>
스크립트
$(function() {
var dateFormat = "mm/dd/yy",
from = $("#sproid-bookingcondition-datefrom")
.datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 1
})
.on("change", function() {
to.datepicker("option", "minDate", getDate(this));
}),
to = $("#sproid-bookingcondition-dateto").datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 1
})
.on("change", function() {
from.datepicker("option", "maxDate", getDate(this));
});
function getDate(element) {
var date;
try {
date = $.datepicker.parseDate(dateFormat, element.value);
} catch(error) {
date = null;
}
return date;
}
});
내 요구 사항은의 일을 가능하게하는 것입니다 사용자 선택에 따라 주. 기본적으로 모든 요일이 활성화됩니다. 예를 들어 사용자가 월요일과 화요일을 선택하면 나머지 날짜 중 나머지는 캘린더에서 사용 중지해야합니다. 이 문제를 해결하기 위해 beforeShowDay
또는 다른 방법을 사용하여이를 어떻게 수행 할 수 있습니까?
는 바이올린에 대한 링크를 참조하십시오 fiddle