Robert Ross
Robert Ross

Reputation: 1189

Disable weekends - bootstrap datepicker

I am trying to make the weekends days on my bootstrap datepicker input inactive.

I tried this :

$(function() {
   $('#datepicker').datepicker({
       beforeShowDay: $.datepicker.noWeekends
   });
});

And this as well :

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

Sadly, none of the worked.

Here is how my BS looks :

<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>

Any help will be appreciated.

Upvotes: 0

Views: 3089

Answers (1)

Brian Glaz
Brian Glaz

Reputation: 15686

I haven't tried providing the daysOfWeekDisabled option in JS, but it did work correctly for me when I used the data attribute version. You can try:

<input type="date" class="form-control" id="datepicker" data-date-days-of-week-disabled="0,6">

Upvotes: 3

Related Questions