$('#datepicker2').datepicker({
format: 'dd-mm-yyyy',
startDate: '0d',
autoclose: true,
}).on('changeDate', function (selected) {
var startDate = new Date(selected.date.valueOf());
var month = Number($("#con_months_of_contract").val());
$('#datepicker4').datepicker('setStartDate', startDate);
startDate.setDate(startDate.getDate() - 1);
startDate.setMonth(startDate.getMonth() + month);
$("#datepicker4").datepicker("setDate", startDate);
}).on('clearDate', function (selected) {
$('#datepicker4').datepicker('setStartDate', null);
});