我正在尝试在 jQuery datepicker 和 asp 日历上阻止日期,例如标签值为“周六,周日”,所以我想阻止所有周六和周日
<asp:Label ID="lblweekoff" runat="server" Font-Size="Medium" Font-Bold="true" ForeColor="Orange">
<asp:TextBox ID="txtdate" class="form-control" autocomplete="off" CssClass="datepicker" runat="server"></asp:TextBox>
我尝试使用 if else 条件来实现这一点,但它不起作用,
<script type="text/javascript">
function jScript() {
$(document).ready(function () {
var lblweekoff = document.getElementById("lblweekoff");
if (lblweekoff.value == "Sat,Sun") {
$('.datepicker').datepicker({
minDate: 0,
dateFormat: "yy/mm/dd",
changeMonth: true,
changeYear: true,
maxDate: 2020,
yearRange: '2018:+' + new Date().getFullYear().toString(),
beforeShowDay: function (date) {
var day = date.getDay();
return [(day != 0 && day != 6)];
}
});
}
else {
$('.datepicker').datepicker({
minDate: 0,
dateFormat: "yy/mm/dd",
changeMonth: true,
changeYear: true,
maxDate: 2020,
yearRange: '2018:+' + new Date().getFullYear().toString()
});
}
}
</script>
Qyouu
相关分类