Skip to content

Commit ddfb801

Browse files
authored
Merge pull request #28 from coennijhuis/coennijhuis-patch-1
Added min- and maxdate validation
2 parents 77d4ccd + da617f6 commit ddfb801

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

js/angular-material-datetimepicker.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,13 @@
216216
ngModel.$parsers.push(function (value) {
217217
if (typeof value === 'undefined') return;
218218
var m = moment(value, scope.format);
219+
if (scope.minDate) {
220+
ngModel.$setValidity('min', !m.isBefore(scope.minDate));
221+
}
222+
if(scope.maxDate) {
223+
ngModel.$setValidity('max', !m.isAfter(scope.maxDate));
224+
}
225+
219226
return m.isValid() ? m.toDate() : '';
220227
});
221228

0 commit comments

Comments
 (0)