简体   繁体   中英

Hide dates in MVC bootstrap datetimepicker based on another datetimepicker

I have two datetimepickers for start date and end date. I want to hide all dates before today in the start date datetimepicker and then I also want to hide all dates before the start date in the end date datetimepicker.

I am doing this in mvc and using the bootstrap pickers.

将startdate赋予datepicker: start date属性。

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

Your datepicker can have the following properties among others, in your view -

   <input max-date="datePicker1.maxDate" min-date="datePicker1.minDate" ng-change="onDatePicker1Change()" ng-model="details.fromDate"/>

and the second date picker could be

<input max-date="datePicker2.maxDate" min-date="datePicker2.minDate" ng-change="onDatePicker2Change()" ng-model="details.fromDate"/>

In your controller activation, initialize appropriate scope values for datePicker1.maxDate, datePicker1.minDate, datePicker2.minDate and datePicker2.maxDate.

Add a onDatePicker1Change() function within the controller which will reset the values for datePicker2.minDate and datePicker2.maxDate appropriately.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM