Работает двумя способами.Так, как вы просили, и наоборот.Наслаждайтесь
var monthNames = [
"January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December"
];
var dayOfWeekNames = [
"Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday"
];
var tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);
$('.d1').datepicker({format: "dd/mm/yyyy", autoclose: true}).val(formatDate(new Date()));
$('.d2').datepicker({format: "dd/mm/yyyy", autoclose: true}).val(formatDate(tomorrow));
function d1_ch (){
var d1_val = convert('/',$('.d1').val()),
d2_val = convert('/',$('.d2').val());
if (d1_val >= d2_val) {
d2_val.setDate(d1_val.getDate() + 1);
$('.d2').datepicker().val(formatDate(d2_val));
}
}
function d2_ch (){
var d1_val = convert('/',$('.d1').val()),
d2_val = convert('/',$('.d2').val());
if (d2_val <= d1_val) {
d1_val.setDate(d2_val.getDate() - 1);
$('.d1').datepicker().val(formatDate(d1_val));
}
}
function convert(delimiter,dateString) {
var splitted = dateString.split('/');
var myDate = new Date(splitted[2],splitted[1]-1,splitted[0]);
return myDate;
}
function formatDate(date, patternStr){
if (!patternStr) {
patternStr = 'dd/MM/yyyy';
}
var day = date.getDate(),
month = date.getMonth(),
year = date.getFullYear(),
hour = date.getHours(),
minute = date.getMinutes(),
second = date.getSeconds(),
miliseconds = date.getMilliseconds(),
h = hour % 12,
hh = twoDigitPad(h),
HH = twoDigitPad(hour),
mm = twoDigitPad(minute),
ss = twoDigitPad(second),
aaa = hour < 12 ? 'AM' : 'PM',
EEEE = dayOfWeekNames[date.getDay()],
EEE = EEEE.substr(0, 3),
dd = twoDigitPad(day),
M = month + 1,
MM = twoDigitPad(M),
MMMM = monthNames[month],
MMM = MMMM.substr(0, 3),
yyyy = year + "",
yy = yyyy.substr(2, 2)
;
// checks to see if month name will be used
if (patternStr.indexOf('MMM') > -1) {
patternStr = patternStr
.replace('MMMM', MMMM)
.replace('MMM', MMM);
}
else {
patternStr = patternStr
.replace('MM', MM)
.replace('M', M);
}
return patternStr
.replace('hh', hh).replace('h', h)
.replace('HH', HH).replace('H', hour)
.replace('mm', mm).replace('m', minute)
.replace('ss', ss).replace('s', second)
.replace('S', miliseconds)
.replace('dd', dd).replace('d', day)
.replace('EEEE', EEEE).replace('EEE', EEE)
.replace('yyyy', yyyy)
.replace('yy', yy)
.replace('aaa', aaa)
;
}
function twoDigitPad(num) {
return num < 10 ? "0" + num : num;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.min.css" rel="stylesheet">
<input class="d1 datepicker" onchange="d1_ch();" value=""/>
<input class="d2 datepicker" onchange="d2_ch();" value=""/>