在jquery中的datatimepicker,可以指定哪些日期是不能被用户选择的,代码如下:
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/themes/base/jquery-ui.css"
type="text/css" media="all" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/jquery-ui.min.js"
type="text/javascript"></script>
<script type="text/javascript">
$(function () {
var daysToDisable = ['12-2-2010', '12-7-2010', '12-10-2010', '12-18-2010'];
$('#<%= txtDate.ClientID %>').datepicker({
beforeShowDay: disableSpecificDates,
dateFormat: 'mm-dd-yy'
});
function disableSpecificDates(date) {
var month = date.getMonth();
var day = date.getDate();
var year = date.getFullYear();
for (i = 0; i < daysToDisable.length; i++) {
if ($.inArray((month + 1) + '-' + day + '-' + year, daysToDisable) != -1) {
return [false];
}
}
return [true];
}
});
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:TextBox ID="txtDate" runat="server"></asp:TextBox>
</form>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/themes/base/jquery-ui.css"
type="text/css" media="all" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/jquery-ui.min.js"
type="text/javascript"></script>
<script type="text/javascript">
$(function () {
var daysToDisable = ['12-2-2010', '12-7-2010', '12-10-2010', '12-18-2010'];
$('#<%= txtDate.ClientID %>').datepicker({
beforeShowDay: disableSpecificDates,
dateFormat: 'mm-dd-yy'
});
function disableSpecificDates(date) {
var month = date.getMonth();
var day = date.getDate();
var year = date.getFullYear();
for (i = 0; i < daysToDisable.length; i++) {
if ($.inArray((month + 1) + '-' + day + '-' + year, daysToDisable) != -1) {
return [false];
}
}
return [true];
}
});
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:TextBox ID="txtDate" runat="server"></asp:TextBox>
</form>
</body>
</html>