Synchronize Two DateBoxes

DateBox widgets are often coupled for selecting a date interval. In this case, you need to synchronize the DateBoxes to prevent a user from selecting an interval whose start date is later than the end date. For this, limit one DateBox's range depending on the other's value as shown in the example below.

jQuery
JavaScript
HTML
$(function() {
    var startDate = $("#startDate").dxDateBox({
        onValueChanged: function(e){
            endDate.option("min", e.value);
        }
    }).dxDateBox("instance");
    var endDate = $("#endDate").dxDateBox({
        onValueChanged: function(e){
            startDate.option("max", e.value);
        }
    }).dxDateBox("instance");
});
<div id="startDate"></div>
<div id="endDate"></div>
Angular
HTML
JavaScript
<dx-date-box 
    [(max)]="endValue"
    [(value)]="startValue">
</dx-date-box>
<dx-date-box 
    [(min)]="startValue"
    [(value)]="endValue">
</dx-date-box>
export class AppComponent {
    startValue: Date;
    endValue: Date;
}
AngularJS
HTML
JavaScript
<div dx-date-box="{
    bindingOptions: {
        max: "endValue"
        value: "startValue"
    }
}"></div>
<div dx-date-box="{
    bindingOptions: {
        min: "startValue"
        value: "endValue"
    }
}"></div>
function Controller($scope) {
    $scope.startValue = {};
    $scope.endValue = {};
}
Knockout
HTML
JavaScript
<div data-bind="dxDateBox: {
    max: endValue
    value: startValue
}"></div>
<div data-bind="dxDateBox: {
    min: startValue
    value: endValue
}"></div>
var viewModel = {
    startDate: ko.observable({}),
    endDate: ko.observable({}),
};
ko.applyBindings(viewModel);

Do not forget to call the getDate() method on the DateBox values when calculating the interval duration.

See Also