-
Notifications
You must be signed in to change notification settings - Fork 420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
min/max limit #37
Comments
That would be very nice indeed. Any ideas on how to implement that? |
I worked on the function isValidDate(value) {
// Invalid Date: getTime() returns NaN
return value && !(value.getTime && value.getTime() !== value.getTime());
}
if (angular.isDefined(attrs.min) || attrs.ngMin) {
var minVal;
ngModel.$validators.min = function (value) {
return !isValidDate(value) || angular.isUndefined(minVal) || value >= minVal;
};
attrs.$observe('min', function (val) {
minVal = new Date(val);
ngModel.$validate();
});
}
if (angular.isDefined(attrs.max) || attrs.ngMax) {
var maxVal;
ngModel.$validators.max = function (value) {
return !isValidDate(value) || angular.isUndefined(maxVal) || value <= maxVal;
};
attrs.$observe('max', function (val) {
maxVal = new Date(val);
ngModel.$validate();
});
} I'll work now on having the calendar limit these dates, and not just validate them. PS.: @g00fy- Would you be kind enough to review and add my code to your source? |
@SuricateCan can you make PR compiling this changes? thanks |
Is min/max limit working for you at all? I'm trying to use it, but as soon as use, let say, Am I doning something wrong? |
@evdoks You can't use "now" in max-date attribute. You have to use a valid, ISO format, date string. |
Yes its true, the readme is wrong! only date string not expressions. |
@evdoks You could extend this functionality by testing the variable before the new Date stuff. |
in the current implementation you can limit the dates by using:
but this still allows the user to navigate to unwanted future days
i think there should be a min/max limit that blocks the user from navigating outside the wanted range, i recommand using the
min
andmax
attribute and integrate them like they work for theinput[date]
elementThe text was updated successfully, but these errors were encountered: