我得到了我的答案。
<html>
<head>
<title>Collection Date</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/jquery-ui.min.js"></script>
<link type="text/css" rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/themes/base/jquery-ui.css" />
</head>
<body>
<form name="Form1" method="post" action="TestDatePicker.asp" id="Form1">
<h2>Collection Form</h2>
<fieldset>
<legend>Choose the collection date</legend>
<div id="datepicker"></div>
<input type="text" id="txtCollectionDate" name="txtCollectionDate" class="requiredField" style="display: none;" />
</fieldset>
<input type="submit" name="submit" value="Submit" />
</form>
<script type="text/javascript">
$(document).ready(function() {
var dateMin = new Date();
//alert(dateMin);
var weekDays = AddWeekDays(5);
alert(weekDays);
alert(weekDays);
dateMin.setDate(dateMin.getDate() + weekDays);
var natDays = [
[1, 1, 'uk'],
[12, 25, 'uk'],
[12, 26, 'uk']
];
function noWeekendsOrHolidays(date) {
var noWeekend = $.datepicker.noWeekends(date);
if (noWeekend[0]) {
return nationalDays(date);
} else {
return noWeekend;
}
}
function nationalDays(date) {
for (i = 0; i < natDays.length; i++) {
if (date.getMonth() == natDays[i][0] - 1 && date.getDate() == natDays[i][2]) {
return [false, natDays[i][2] + '_day'];
}
}
return [true, ''];
}
function AddWeekDays(weekDaysToAdd) {
var daysToAdd = 0
var mydate = new Date()
//alert(mydate);
var day = mydate.getDay()
//alert(day);
// alert(weekDaysToAdd);
weekDaysToAdd = weekDaysToAdd - (5 - day)
if ((5 - day) < weekDaysToAdd || weekDaysToAdd == 1) {
daysToAdd = (5 - day) + 2 + daysToAdd
} else { // (5-day) >= weekDaysToAdd
daysToAdd = (5 - day) + daysToAdd
}
while (weekDaysToAdd != 0) {
var week = weekDaysToAdd - 5
if (week > 0) {
daysToAdd = 7 + daysToAdd
weekDaysToAdd = weekDaysToAdd - 5
} else { // week < 0
daysToAdd = (5 + week) + daysToAdd
weekDaysToAdd = weekDaysToAdd - (5 + week)
}
}
return daysToAdd;
}
$('#datepicker').datepicker(
{
inline: true,
beforeShowDay: noWeekendsOrHolidays,
altField: '#txtCollectionDate',
showOn: "both",
dateFormat: "dd/mm/yy",
changeFirstDay: false,
minDate: dateMin
});
});
</script>
</body>
</html>
截屏:
谁知道这个国庆节怎么过