How to inactive previous date in Bootstrap datepicker?

扶醉桌前 提交于 2019-12-13 03:38:30

问题


I'm using Bootstrap datepicker and I want to inactive previous date. Means the user should not be able to select the previous day. I want this to develop functionality to schedule some users work.

What I need to do?


回答1:


The following code will disable date after today.

var nowTemp = new Date();
var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0);                    
$('#myId').datepicker({
        format: 'dd-mm-yyyy',
        onRender: function(date) {
        return date.valueOf() > now.valueOf() ? 'disabled' : '';
        }
});



回答2:


Try this:

$("#Date").datepicker({dateFormat: 'MM dd, yy', minDate: 0 });


来源:https://stackoverflow.com/questions/25053119/how-to-inactive-previous-date-in-bootstrap-datepicker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!