-1

I have a BS input with type="date" and all I am trying to do is to disable past days and weekends in my calendar. I tried numerous snippets of code found on the internet and invented by me, but nothing worked, probably because I lack understanding how to make them work.

So please help. Any tips will be appreciated.

Here is my html :

<div class="form-group">
   <label class="control-label col-sm-2" for="date" ">Date:</label>
   <div class="col-sm-2">
      <input type="date" class="form-control" id="datepicker">
   </div>
</div>
Aniket Sahrawat
  • 12,410
  • 3
  • 41
  • 67
Robert Ross
  • 1,151
  • 2
  • 19
  • 47

2 Answers2

2

Try following, it will indicate minimum date & weekend disable in this control.

 $(function() {
      $( "#datepicker" ).datepicker({
        beforeShowDay: $.datepicker.noWeekends,
        minDate : 'now'
     });
 });
ScanQR
  • 3,740
  • 1
  • 13
  • 30
0

you can set a start data like this:

var date = new Date();
date.setDate(date.getDate()-1);

$('#date').datepicker({ 
    startDate: date
});

and disble any day you want with this:

$('#datepicker').datepicker({
    daysOfWeekDisabled: [0,6]
});