Skip to content

Commit 3a671ef

Browse files
rcdextadalelotts
authored andcommitted
Add example to illustrate specifying mindate in the form of restricting past dates
1 parent a3c352a commit 3a671ef

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,27 @@ In this example, the drop-down functionality is controlled by Twitter Bootstrap.
340340
The <code>dropdownSelector</code> tells the datetimepicker which element is bound to the Twitter Bootstrap drop-down so
341341
the drop-down is toggled closed after the user selects a date/time.
342342

343+
### Restrict past dates from being selected
344+
345+
```html
346+
<datetimepicker data-ng-model="startDate" data-before-render="startDateBeforeRender($dates)">
347+
</datetimepicker>
348+
```
349+
350+
We filter dates that are past today and set selectable to false
351+
352+
```javascript
353+
$scope.startDateBeforeRender = function($dates) {
354+
const todaySinceMidnight = new Date();
355+
todaySinceMidnight.setUTCHours(0,0,0,0);
356+
$dates.filter(function (date) {
357+
return date.utcDateValue < todaySinceMidnight.getTime();
358+
}).forEach(function (date) {
359+
date.selectable = false;
360+
});
361+
};
362+
```
363+
343364
### Create a date range picker with validation controls
344365
```html
345366
<div class="dropdown form-group">

0 commit comments

Comments
 (0)