Reputation: 21
I have a date time picker.I need to restrict future dates. For Eg:I want to restrict the future dates from current date.
Code Sample
$('.datetimepicker').datetimepicker({
format: 'mm-dd-yyyy',
autoclose:true,
endDate: "today",
maxDate: today
});
Anyone please help me.
Upvotes: 1
Views: 352
Reputation: 3012
You can simply use a Date object from javascript, to limit the selection, for example:
$(function () {
var today = new Date();
$('#datetimepicker1').datetimepicker({
format: 'MM-DD-YYYY',
minDate: today,
maxDate: new Date(today.getTime() + 7 * 24 * 60 * 60 * 1000) // 1 week from today
});
});
The following formats are also allowed: string, Date, moment, boolean:false
working example: https://jsfiddle.net/amop9r3q/5/
docs: http://eonasdan.github.io/bootstrap-datetimepicker/Functions/#minmaxdate
Upvotes: 1