I solved it with the dateRange Datepicker instead of using 2 different Datepickers then i calculate the number of days in the range and reply it into a textfield as you needed. I hope it helps.
HTML
<form>
<label>From</label>
<input id="from" readonly="readonly" name="from" type="text" value="">
<label>To</label>
<input id="to" readonly="readonly" name="to" type="text" value="">
<label>Days</label>
<input id="days" readonly="readonly" name="days" type="text" value="">
</form>
jQuery UI
<script>
var from = new Date();
var to = new Date();
var dayDiff = 1;
$(function() {
var dates = $( "#from, #to" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 1,
onSelect: function( selectedDate ) {
var option = this.id == "from" ? "minDate" : "maxDate",
instance = $( this ).data( "datepicker" ),
date = $.datepicker.parseDate(
instance.settings.dateFormat ||
$.datepicker._defaults.dateFormat,
selectedDate, instance.settings );
dates.not( this ).datepicker( "option", option, date );
if (this.id == "from"){
from = $(this).datepicker('getDate');
if (!(to == "")){
update_days()
}
}
if (this.id == "to"){
to = $(this).datepicker('getDate');
update_days()
}
}
});
});
function update_days(){
dayDiff = Math.ceil((to - from) / (1000 * 60 * 60 * 24));
$("#days").empty()
$("#days").append(dayDiff)
}
</script>