I want to validate the datepicker input control to disable all past dates, ie all dates from the current date only should be enabled.
I tried using the bootstrap-datepicker library and used the js code below for the validation but I'm still a
$('.input-group.date').datepicker({ autoclose: true, daysOfWeekDisabled: [0, 6], todayHighlight: true, format: "dd-mm-yyyy", startDate: new Date() });
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.0/jquery.min.js"></script> <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker3.css" rel="stylesheet"/> <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.js"></script> <form action="#" method="POST"> <div class="input-group date" data-provide="datepicker"> <input type="text" class="form-control"> <div class="input-group-addon"> <span class="glyphicon glyphicon-th"></span> </div> </div> </form>
I'm still able to select all past dates.
$('.input-group.date').datepicker({
autoclose: true,
daysOfWeekDisabled: [0, 6],
todayHighlight: true,
format: "dd-mm-yyyy",
startDate: '0d';
});
<form action="#" method="POST">
<div class="input-group date" data-provide="datepicker">
<input type="text" class="form-control">
<div class="input-group-addon">
<span class="glyphicon glyphicon-th"></span>
</div>
</div>
</form>
<script src="{{ asset('assets/js/bootstrap-datepicker.min.js') }}"></script>
<link rel="stylesheet" href="{{ asset('assets/css/bootstrap-datepicker3.min.css') }}">
I want all past dates to be disabled.
I was able to figure out the problem after checking my console to see the error being displayed each I load the page.
Re-arranging my js libraries solved it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.