Javascript或Jquery日历,应从当前日期以及周末隐藏以前的日期

问题描述

|| 需要使用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>
它不会禁用过去的日期或周末,但它是如此简单,您可能可以对其进行调整。     

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...