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.

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

1 Comment

I just refreshed the plunker... I hadn't saved my changes
0

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.