但是现在要在日历上增加一个小功能,可提供选择日期不超过当前日期,比如今天是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>