jeDate可提供选择日期不超过当前日期

简介: jeDate可提供选择日期不超过当前日期

但是现在要在日历上增加一个小功能,可提供选择日期不超过当前日期,比如今天是8.5号,超出5号以后的日期都默认不可选。

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <input placeholder="开始时间" id="startTime"  type="text"> 
        <input  placeholder="结束时间" id="stopTime"  type="text">
    </body>
    <link type="text/css" rel="stylesheet" href="jeDate-gh-pages/test/jeDate-test.css">
    <link type="text/css" rel="stylesheet" href="jeDate-gh-pages/skin/jedate.css">
    <script type="text/javascript" src="jeDate-gh-pages/src/jedate.js"></script>
    <script>
        Date.prototype.format = function(format) {
            var o = {
                "M+" : this.getMonth() + 1, // month
                "d+" : this.getDate(), // day
                "h+" : this.getHours(), // hour
                "m+" : this.getMinutes(), // minute
                "s+" : this.getSeconds(), // second
                "q+" : Math.floor((this.getMonth() + 3) / 3), // quarter
                "S" : this.getMilliseconds()
            // millisecond
            };
            if (/(y+)/.test(format)) {
                format = format.replace(RegExp.$1, (this.getFullYear() + "")
                        .substr(4 - RegExp.$1.length));
            }
            for ( var k in o) {
                if (new RegExp("(" + k + ")").test(format)) {
                    format = format.replace(RegExp.$1,
                            RegExp.$1.length == 1 ? o[k] : ("00" + o[k])
                                    .substr(("" + o[k]).length));
                }
            }
            return format;
        };
        var nowt = new Date().format("yyyy-MM-dd");
        //选中后点确定按钮才关闭
        jeDate("#startTime", {
            onClose : true,
            theme : {
                bgcolor : "#00A1CB",
                color : "#ffffff",
                pnColor : "#00CCFF"
            },
            format : 'YYYY-MM-DD',
            maxDate : nowt
        });
        jeDate("#stopTime", {
            onClose : true,
            theme : {
                bgcolor : "#00A1CB",
                color : "#ffffff",
                pnColor : "#00CCFF"
            },
            format : 'YYYY-MM-DD',
            maxDate : nowt
        });
    </script>
</html>
相关文章
|
3月前
|
存储 C语言 C++
c++日期和时间
c++日期和时间
31 0
|
3月前
|
C语言 C++
c++日期&时间
c++日期&时间
36 1
|
9月前
根据日期获得当天是星期几?
根据日期获得当天是星期几?
55 0
判断月份天数
判断月份天数
44 0
|
存储 Linux 编译器
C++ 日期和时间的相关函数
C++ 日期和时间的相关函数
277 0
1229. 日期问题
1229. 日期问题
59 0
获取当前日期和时间
获取当前日期和时间
155 0
|
Java
获取当前日期时间
获取当前日期时间
135 0
|
JavaScript 前端开发