datepicker change date code example

Example 1: datepicker on change

$("#datepicker").on("change",function(){
        var selected = $(this).val();
        alert(selected);
    });

Example 2: on change datepicker and change date increase date in another fuilds

$('#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);
	//set -1 date
	startDate.setDate(startDate.getDate() - 1);
	//select months set new date
  	startDate.setMonth(startDate.getMonth() + month);
	$("#datepicker4").datepicker("setDate", startDate);
}).on('clearDate', function (selected) {
	$('#datepicker4').datepicker('setStartDate', null);
});
//@sujay