问题描述
||
需要使用Javascript或Jquery的日历脚本,该日历脚本应具有从当前日期禁用所有先前日期的选项,并且还禁用周六和周日的选项
解决方法
您可以使用jQuery ui datepicker
您可以使用
minDate
和maxDate
选项禁用以前的日期
检查此选项,禁用周六和周日
,这是JavaScript中非常简单的日历脚本:
<table border=\"1\">
<tr>
<td>M</td> <td>T</td> <td>W</td> <td>T</td> <td>F</td> <td>S</td> <td>S</td>
</tr>
<script language=\"JavaScript\"> <!--
// find the first day of the current month
function firstDay() {
d = new Date(); // d is today\'s date
d.setDate(1); // set d to the 1st of this month
day = d.getDay(); // day of week - 0=Sunday,1=Monday... etc.
if (day==0) {
return 6;
} else {
return day-1;
}
}
var week = 0; // week of the month
var weekDay = 0; // day of the week
var day; // day of the month
var startingDay = firstDay(); // day the month starts,0 to 6
for (week=0; week<=5; week++) {
document.write(\"<tr>\");
for (weekDay=1; weekDay<=7; weekDay++) {
document.write(\"<td>\");
day = 7*week+weekDay;
day -= startingDay;
if (day>0 && day<=31) { document.write(day); }
document.write(\"</td>\");
}
document.write(\"</tr>\");
}
--> </script>
<table>
它不会禁用过去的日期或周末,但它是如此简单,您可能可以对其进行调整。