设置easyui datebox 日期选择器不能选择今天之后的日期

代码如下:

html

<input class="easyui-datebox" id="date" name="date" value="<%$date%>" style="width:180px" />

javascript

$('#date').datebox('calendar').calendar({  
    validator: function (date) {  
        var now = new Date();  
        var today = new Date(now.getFullYear(), now.getMonth(), now.getDate());  
        return today >= date;  
    }  
});

同理,限制只能选择十天之内的数据

$('#date').datebox('calendar').calendar({  
    validator: function(date){  
        var now = new Date();  
        var d1 = new Date(now.getFullYear(), now.getMonth(), now.getDate());  
        var d2 = new Date(now.getFullYear(), now.getMonth(), now.getDate()+10);  
        return d1<=date && date<=d2;  
    }  
});
© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发

请登录后发表评论