我的应用程序要求日期选择器在单击时显示日历正文,选择“日期”“今天的活动日期”和“将来的停用日期”。。。我是jquery的新员工,一个月来一直困扰着我。请帮忙。我可以显示日期选择器并选择2030年之前的任何日期,但我需要日历仅在今天或当前日期之前处于活动状态。
提前谢谢。
我的日历要展示。。

<table id="calenderTable" class="">
                <tbody id="calenderTableHead">
                    <tr>
                        <td colspan="4" align="center">
                            <select onChange="showCalenderBody(createCalender(document.getElementById('selectYear').value,
                                this.selectedIndex, false));" id="selectMonth">
                                <option value="0">Jan</option>
                                <option value="1">Feb</option>
                                <option value="2">Mar</option>
                                <option value="3">Apr</option>
                                <option value="4">May</option>
                                <option value="5">Jun</option>
                                <option value="6">Jul</option>
                                <option value="7">Aug</option>
                                <option value="8">Sep</option>
                                <option value="9">Oct</option>
                                <option value="10">Nov</option>
                                <option value="11">Dec</option>
                            </select>
                        </td>
                        <td colspan="2" align="center">
                            <select onChange="showCalenderBody(createCalender(this.value,
                document.getElementById('selectMonth').selectedIndex, false));" id="selectYear">
                            </select>
                        </td>
                        <td align="center">
                            <a href="#" onClick="closeCalender();"><font color="#003333" size="+1">X</font></a>
                        </td>
                    </tr>
                </tbody>
                <tbody id="calenderTableDays">
                    <tr style="">
                        <td>Sun</td><td>Mon</td><td>Tue</td><td>Wed</td><td>Thu</td><td>Fri</td><td>Sat</td>
                    </tr>
                </tbody>
                <tbody id="calender"></tbody>
            </table>

日期字段如下:
    <tr>
       <td>effected date</td>
             <td>
                 <input type="text" name="eff_date" class="required" id="eff_date"><a href="#" onClick="setYears(1947, 2030);
 showCalender(this, 'eff_date');" class="" id="calender">
   <img src="Calender/calender.png"></a>
              </td>
      </tr>

最佳答案

假设我理解这个问题,这很容易完成。您要设置最大允许的可选择日期,对吗?您只需要使用maxDate选项。
下面是一个完整的示例,假设您包含脚本和链接标记中引用的正确文件:

<!DOCTYPE HTML>
<html>
<head>
    <title>date</title>
    <meta charset="utf-8">
    <link type="text/css" href="css/ui-lightness/jquery-ui-1.8.18.custom.css" rel="stylesheet" />
    <script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
    <script type="text/javascript" src="js/jquery-ui-1.8.18.custom.min.js"></script>
</head>
<body>
    <div class="demo">
        <p>Date: <input type="text" id="datepicker"></p>
    </div>
<script>
$(function() {
    $("#datepicker").datepicker({maxDate: '+0d'});
});
</script>
</body>
</html>

你可以看到它在这里工作:
http://gigaloop.com/answers/date.html

07-24 09:48
查看更多