问题
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