Bootstrap Datepicker unable to set start/end dates
16,519
Solution 1
Looks like the problem was I had an out of date version of bootstrap-datepicker.js.
A coworker just picked up the plugin so I'm not sure why he downloaded an out of date version, oh well.
Solution 2
Try this code, worked for me. disabled dates prior to today
$("YOURSELECTOR").datepicker({
format: 'dd/mm/yyyy',
startDate:new Date()
});
Remember this is bootstrap picker
Solution 3
<script type="text/javascript">
$(function () {
$('#flight_start').datepicker({
format: "mm-dd-yyyy",
startDate: "04-07-2010",
endDate: "04-07-2014"
});
});
</script>
Related videos on Youtube
Author by
Wes
Updated on September 14, 2022Comments
-
Wes over 1 year
Here is code:
<input type="text" class="datepicker" id="flight_start" placeholder="mm-dd-yyyy" data-date-format="mm-dd-yyyy"> ... <script src="/ui/js/jquery.js"></script> <script src="/ui/js/bootstrap.js"></script> <script src="/ui/js/datatables/jquery.dataTables.min.js"></script> <script src="/ui/js/datatables/DT_bootstrap.js"></script> <script src="/ui/js/responsive-tables/responsive-tables.js"></script> <script src="/ui/js/datepicker/date.js"></script> <script src="/ui/js/datepicker/daterangepicker.js"></script> <script src="/ui/js/chosen/chosen.jquery.js"></script> <script src="/ui/js/bootstrap-wizard/bootstrap-wizard.js"></script> <script src="/ui/js/sparkline/jquery.sparkline.min.js"></script> <script src="/ui/js/datepicker/bootstrap-datepicker.js"</script> ... <script type="text/javascript"> $('#flight_start').datepicker({ format: "mm-dd-yyyy", startDate: "+1d" }); </script>
The format works, but not the start date. I get no errors/warnings, simply does not work. Dates prior to the start date are not grayed out in any way and can be selected. I want to remove this ability. Thanks!
Edit: I've also tried
$('#flight_start').datepicker('setStartDate', '+1d');
Which gives me
Uncaught TypeError: Object [object Object] has no method 'setStartDate'