Thomas
Thomas

Reputation: 213

How to dynamically set min date and max date in date picker angular js with bootstrap 3

I am using two date picker:

  1. start date
  2. end-date

I need to set max date in start date based in end-date value and min date in end-date based in start-date value

How to dynamically change the min and max value based on the date change in the date picker

I am using angular date picker with bootstrap 3

Upvotes: 2

Views: 7929

Answers (2)

Anusha Bhat
Anusha Bhat

Reputation: 431

The following code is for singleDatePicker:

{
    singleDatePicker: true,
    maxDate:  moment(), //this for current date
    minDate : moment().subtract(1, 'days'), // this is for previous date
    locale: {
        format: 'YYYY-MM-DD'
    }
}

Upvotes: 0

Sachindeep Singh
Sachindeep Singh

Reputation: 59

You can set the the min and max attributes for the two date pickers in the following way.

<input type="date" ng-model="date1" max="{{date2 | date:'yyyy-MM-dd'}}">
<input type="date" ng-model="date2" min="{{date1 | date:'yyyy-MM-dd'}}">

Upvotes: 2

Related Questions