Reputation: 1446
I am using bootstrap datetimepicker (http://eonasdan.github.io/bootstrap-datetimepicker/#linked-pickers) but am having trouble getting the linked-pickers to work properly. I am using the suggested coding that they are but for some reason the mindate and maxdate are not working properly. Will someone please tell me what I may be doing wrong?
$(document).ready(function () {
$('#datetimepicker1')
.datetimepicker({
showTodayButton: true,
format: 'MM/DD/YYYY'
});
$('#datetimepicker2')
.datetimepicker({
showTodayButton: true,
format: 'MM/DD/YYYY'
});
$("#datetimepicker1").on("dp.change", function (e) {
$('#datetimepicker2').data("DateTimePicker").minDate(e.date);
});
$("#datetimepicker2").on("dp.change", function (e) {
$('#datetimepicker1').data("DateTimePicker").maxDate(e.date);
});
});
Upvotes: 0
Views: 5478
Reputation: 1425
So after looking at the examples in the docs and the outputs in your jfiddle, I came to the conclusion that the documents and the version you're using of the datetimepicker must not match. Or the documentation hasn't been updated. Either way, in your fiddle if you use setMinDate
and setMaxDate
you should be good. E.g:
instead of
$("#datetimepicker1").on("dp.change", function (e) {
$('#datetimepicker2').data("DateTimePicker").minDate(e.date);
});
simply do
$("#datetimepicker1").on("dp.change", function (e) {
$('#datetimepicker2').data("DateTimePicker").setMinDate(e.date);
});
this will disable the date selection in the manner that i believe you want.
Upvotes: 1