Reputation: 233
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
});
Upvotes: 12
Views: 27982
Reputation: 51
to disable past dates use startDate instead of minDate. like this...
$('#checkinDate').datepicker({
format: "dd/mm/yyyy",
autoclose: true,
startDate: new Date()
});
Upvotes: 2
Reputation: 11
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()
});
});
Upvotes: -1
Reputation: 1072
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',
});
Upvotes: 5
Reputation: 2852
For jquery datepicker use:
$(".datepicker").datepicker({
minDate: 0
});
For Bootstrap versions use:
$(".datepicker").datepicker({
startDate: new Date()
});
Upvotes: 43
Reputation: 8386
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
});
Upvotes: 0
Reputation: 11665
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 });
Upvotes: 0