I'm using a AdminLte template for my CodeIgniter application, and from that I'm using a Datepicker plugin. I'm trying to add minDate
functionality to restrict user to access previous date from current date, but the minDate: 0
is not working and I'm able to pick previous date also.
Here is my JS:
$('#datepicker5').datepicker({
autoclose: true,
//changeYear: true,
minDate: 0,
});
and
$('#datepicker5').datepicker({
autoclose: true,
//changeYear: true,
minDate: new Date(),
})
Today's date is 12 Dec. 2017 but I can select previous date also. Both are not working.
I'm using two date pickers with two different ID's. One is datepicker4
and datepicker5
, and I'm calculating diff. between them. For that I've written following JS:
$('#datepicker4').datepicker();
$('#datepicker5').datepicker();
$('#datepicker5').change(function () {
var gasDiff= $('#datepicker4').datepicker("getDate") - $('#datepicker5').datepicker("getDate");
var result = gasDiff / (1000 * 60 * 60 * 24) * -1;
document.getElementById("gasDiff").value = result;
});
Even I can able to select expiry date before issue date. Actually I want to pick issue date before or current date, and expiry date after current date.
Edit:
$('#datepicker1').datepicker({
autoclose: true,
endDate: new Date(),
todayHighlight: true,
});
$("#datepicker1").on("change",function(){
var selected = "Are you sure you want to select this date ?";
alert(selected);
});
//$('#datepicker1')..inputmask('dd/mm/yyyy', { 'placeholder': 'dd/mm/yyyy' });
$('#datepicker2').datepicker({
autoclose: true,
todayHighlight: true,
startDate: new Date(),
});
$('#datepicker1', '#datepicker2').change(function(){
var certDiff= $('#datepicker1').datepicker("getDate") - $('#datepicker2').datepicker("getDate");
var result = certDiff / (1000 * 60 * 60 * 24) * -1;
//("#certDiff").text(result);
document.getElementById("certDiff").value = result;
//document.getElementById("certDiff").innerHTML = result;
});
Please any kind of help is welcome, Thanks in advance.