'jQuery Datepicker minDate is not working in bootstrap
I'm trying to set a minDate for a jquery datepicker. but itz is not working.
$('.datepicker').datepicker({
autoclose: true,
todayHighlight: true,
format: "dd-mm-yyyy",
minDate: new Date(),
clearBtn: true,
multidate: false,
multidateSeparator: ",",
toggleActive: true
});
Solution 1:[1]
For jquery datepicker use:
$(".datepicker").datepicker({
minDate: 0
});
For Bootstrap versions use:
$(".datepicker").datepicker({
startDate: new Date()
});
Solution 2:[2]
In newer bootstrap datepicker version use below method
limiting end date **eg** +1d, +3m, +5y , -1d , -3m, -5y
limiting start date **eg** +1d, -23d, +3m ,2y, -2y
$('#dob').datepicker({
fautoclose: true,
startDate: '+1y',
});
$('#dob').datepicker({
fautoclose: true,
endDate: '-18y',
});
Solution 3:[3]
to disable past dates use startDate instead of minDate. like this...
$('#checkinDate').datepicker({
format: "dd/mm/yyyy",
autoclose: true,
startDate: new Date()
});
Solution 4:[4]
Try to change minDate to 0
$('.datepicker').datepicker({
autoclose: true,
todayHighlight: true,
format: "dd-mm-yyyy",
minDate: 0,
clearBtn: true,
multidate: false,
multidateSeparator: ",",
toggleActive: true });
Solution 5:[5]
According to jQuery datepicker api doc http://api.jqueryui.com/datepicker/#option-minDate, if you want to set today as minDate then minDate should be 0.
here is the working fiddle: http://jsfiddle.net/0dn4mtxn/1/
Try this:
$('.datepicker').datepicker({
autoclose: true,
todayHighlight: true,
format: "dd-mm-yyyy",
minDate: 0,
clearBtn: true,
multidate: false,
multidateSeparator: ",",
toggleActive: true
});
Solution 6:[6]
you can use php date function like this:
this is workingg..?
$(document).ready(function(){
$('#Sdate').datetimepicker({
minDate:'<?php echo date('Y-m-d H:i:s');?>'
});
});
or you can use this
$(document).ready(function(){
$('#Sdate').datetimepicker({
minDate: new Date()
});
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | ReNiSh AR |
Solution 2 | Syed Shibli |
Solution 3 | hardik kanzariya |
Solution 4 | anjaneyulubatta505 |
Solution 5 | Monzurul Shimul |
Solution 6 |