$(function () {
$("#from").datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 3,
onClose: function (selectedDate) {
$("#to").datepicker("option", "minDate", selectedDate);
}
});
$("#to").datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 3,
onClose: function (selectedDate) {
$("#from").datepicker("option", "maxDate", selectedDate);
}
});
});
$("#to").change(function () {
var final = $("#to").datepicker("getDate");
var start = $("#from").datepicker("getDate");
var days = new Date(final - start);
alert(days);
});
<label for="from">From</label>
<input type="text" id="from" name="from" />
<label for="to">to</label>
<input type="text" id="to" name="to" />
This is what I have by far, I pretend to get the number of days passed between 2 dates everytime that final date is filled. I'm having some trouble because of conversions :s