You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 29, 2019. It is now read-only.
Is it possible to mark the field as invalid until they have formatted the date like provided? For instance, if I am typed:
10
It treats this as a valid date (october 1, 2001) . I would rather treat this as invalid, until I completed by typing of my date like:
10/20/2014
The text was updated successfully, but these errors were encountered:
Agreed. Several inputs are not valid, but all are treated as valid. Model should be set to invalid if date 1) is not valid and 2) does not match format requested.
Example of invalid dates that are not set invalid with a format of MM/dd/yyyy:
I think I am encountering a similar issue. The date from the datepickerpopup marks a date valid even if the date does not match the format.
I found this line inside of the datepickerPopup parseDate function:
var date = dateParser.parse(viewValue, dateFormat) || new Date(viewValue);
if (isNaN(date)) {
ngModel.$setValidity('date', false);
return undefined;
} else {
ngModel.$setValidity('date', true);
return date;
}
The call to the dateParser service returns undefined if the date fails validation based on some regex rules defined in it.
The other side of the or expression attempts to create new date object with the value passed in.
If the new Date logic was removed from the or expression and the date is set as undefined, then the if check for isNaN(date) would pass and the model will be set to invalid.
Not sure if that would be an acceptable solution, but the date would be undefined and the model would be set to invalid in this case.
If someone is using a datepicker with popup, like here:
http://angular-ui.github.io/bootstrap/#/datepicker
Is it possible to mark the field as invalid until they have formatted the date like provided? For instance, if I am typed:
10
It treats this as a valid date (october 1, 2001) . I would rather treat this as invalid, until I completed by typing of my date like:
10/20/2014
The text was updated successfully, but these errors were encountered: