I included the bootstrap datepicker in my form. the beforeShowDay() is working only after the first click on the date or the previous month arrow(>>). Can you please help me so that it works on open itself.
Here is the code i tried.
$(document).ready(function(){
$('#ReportFromDate').datepicker({
autoclose:true,
endDate: new Date(),
format: "mm/dd/yyyy",
language : 'pt-BR'
});
$('#ReportToDate').datepicker({
autoclose:true,
beforeShowDay: function (date) {
var endDate1 = new Date();
var startDate1 = new Date($('#ReportFromDate').val());
console.log("new "+ startDate1 +" "+endDate1);
if (date.valueOf() <= endDate1.valueOf() && date.valueOf() >= startDate1.valueOf()) {
return (date.valueOf() <= endDate1.valueOf() && date.valueOf() >= startDate1.valueOf());
} else {
return false;
}
},
format: "mm/dd/yyyy"
});
});
Aucun commentaire:
Enregistrer un commentaire