$("#inputEndDate").datepicker("clearDates");
$("#inputEndDate").datepicker("setStartDate", new Date($("#inputStartDate").val()));
})
`
I can't get the setStartDate or setEndDate to work. They just don't seem to do anything. I've tried setting data-date-start-date but had no success down that route. It works fine when I set startDate on instantiation.
Datepicker version used
ex. 1.7.1.
I incorporated the code from this fiddle (https://jsfiddle.net/qwc0dwLa/1/) and managed to get two datepickers to interact. The only difference I can see is that mine is using the daterange.
So I managed to get setStartDate to do something...
The issue was that I was passing a moment rather than a Date..
var from = $(this).val().split("-");
var f = new Date(from[2], from[1] - 1, from[0]);
$('#inputEndDate').datepicker('setStartDate', f);
However, calling setStartDate (or setEndDate) for that matter trashes all my options that I setup when I instanciated the datepickers. Given the amount of time I've spent on this and the pitiful progress I've made, no option now but to hack the code. :-(
I'm trying to have a start and end date that work with each other (i.e. start date cannot be after end date and vice versa).
`
...and...
` $('.input-group.date, .input-daterange').datepicker({ keyboardNavigation: false, showOnFocus: false, autoclose: true });
// $("#inputDate").attr('data-date-start-date', '01-02-2018');
` I can't get the setStartDate or setEndDate to work. They just don't seem to do anything. I've tried setting data-date-start-date but had no success down that route. It works fine when I set startDate on instantiation.
Datepicker version used
ex. 1.7.1.
I incorporated the code from this fiddle (https://jsfiddle.net/qwc0dwLa/1/) and managed to get two datepickers to interact. The only difference I can see is that mine is using the daterange.
Any advice greatly appreciated.
I had a similar issue and this solution worked for me: https://github.com/uxsolutions/bootstrap-datepicker/issues/1818#issuecomment-200030641
@yugenekr Thanks, but how do I set a start or end date? The setStartDate doesn't seem to do anything.
So I managed to get setStartDate to do something...
The issue was that I was passing a moment rather than a Date..
var from = $(this).val().split("-"); var f = new Date(from[2], from[1] - 1, from[0]); $('#inputEndDate').datepicker('setStartDate', f);
However, calling setStartDate (or setEndDate) for that matter trashes all my options that I setup when I instanciated the datepickers. Given the amount of time I've spent on this and the pitiful progress I've made, no option now but to hack the code. :-(