[英]jQuery UI Datepicker Your selected date is a Saturday or Sunday
I am using datepicker and if someone selects a Saturday or Sunday display alert mesage Your selected date is a Saturday or Sunday, do you wish to continue?我正在使用 datepicker,如果有人选择周六或周日显示警报消息 您选择的日期是周六或周日,您要继续吗?
If user click on OK then it process otherwise it close window如果用户单击确定然后它处理否则它关闭 window
<input type="text" name="inspectiondate <? echo $sno; ?>" id="inspectiondate<? echo $sno; ?>" placeholder="Date" class="required-entry date" style="width:100px !important;" readonly="readonly" autofocus require>
<img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN). 'adminhtml/default/default/images/grid-cal.gif'; ?>" alt="" class="v-middle date" id="Idate<? echo $sno; ?>" title="Select Date" onclick="setcal(<? echo $sno; ?>)">
You need to handle event of your datepicker where you will get selected date's day of the week.您需要处理日期选择器的事件,您将在其中获得选定日期的星期几。
<!doctype html>
<html lang = "en">
<head>
<meta charset = "utf-8">
<title>jQuery UI Datepicker functionality</title>
<link href = "https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css"
rel = "stylesheet">
<script src = "https://code.jquery.com/jquery-1.10.2.js"></script>
<script src = "https://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<!-- Javascript -->
<script>
$(function() {
$( "#datepicker-13" ).datepicker();
$("#datepicker-13")
.datepicker({
onSelect: function(dateText) {
console.log("Selected date: " + dateText + "; input's current value: " + this.value);
$(this).change();
}
})
.on("change", function() {
var date = $(this).datepicker('getDate');
var dayOfWeek = date.getUTCDay();
if(dayOfWeek == 5 || dayOfWeek == 6)
{
//your alert code
alert(dayOfWeek)
}
});
});
</script>
</head>
<body>
<!-- HTML -->
<p>Enter Date: <input type = "text" id = "datepicker-13"></p>
</body>
</html>
you can check working demo in below link.您可以在下面的链接中查看工作演示。
https://jsfiddle.net/bc4nr5we/ https://jsfiddle.net/bc4nr5we/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.