2

I am using the datepicker of UI Bootstrap: (there is a Plunker there that disable the past dayswith a button).

Can anyone please help me to disable the future days without any button?

I tried change the function of the button like that, but it didn't worked:

$scope.toggleMin = function() { $scope.options.minDate = $scope.options.minDate ? **new Date()** : **null** ; };

And this is a button, I'd like to disable without a button.

kfm
  • 143
  • 3
  • 17

2 Answers2

4

Just set maxDate in options to the date you want to restrict to.

$scope.options = {
  customClass: getDayClass,
  maxDate: new Date(), // restrict maximum date to today
  showWeeks: true
};

Otherwise, if you need to change it after the options are set you can just do:

$scope.options.maxDate = new Date(), // restrict maximum date to today

Here's the updated Plunker with days after today disabled: https://plnkr.co/edit/0iqNNEcATzv4t8h8n41X?p=preview

K Scandrett
  • 16,390
  • 4
  • 40
  • 65
0

Set your datepicker class and Set endDate = new Date()

    $('.date-datepicker').datepicker({
        autoclose: true,
        endDate: new Date()
    });
rvchauhan
  • 89
  • 8