$(document).ready(function () {
$("#date1").datepicker({ minDate: new Date(2012, 7 - 1, 8), maxDate: new Date(2012, 7 - 1, 28) });
//$("#date2").datepicker({ minDate: new Date(2012, 7 - 1, 9), maxDate: //new Date(2012, 7 - 1, 28) });
$('#date1, #date2').datepicker({onSelect: function(dateStr) {
var d1 = $('#date1').datepicker('getDate');
var d2 = $('#date2').datepicker('getDate');
var diff = 0;
if (d1 && d2) {
diff = Math.floor((d2.getTime() - d1.getTime()) / 86400000); // ms per day
}
$('#calculated').val(diff);
}
});
});
Check Js Fiddle : http://jsfiddle.net/MebwN/48/
$("#date1").datepicker({ minDate: new Date(2012, 7 - 1, 8), maxDate: new Date(2012, 7 - 1, 28) });
//$("#date2").datepicker({ minDate: new Date(2012, 7 - 1, 9), maxDate: //new Date(2012, 7 - 1, 28) });
$('#date1, #date2').datepicker({onSelect: function(dateStr) {
var d1 = $('#date1').datepicker('getDate');
var d2 = $('#date2').datepicker('getDate');
var diff = 0;
if (d1 && d2) {
diff = Math.floor((d2.getTime() - d1.getTime()) / 86400000); // ms per day
}
$('#calculated').val(diff);
}
});
});
Check Js Fiddle : http://jsfiddle.net/MebwN/48/
Comments
Post a Comment