I am trying to create a validator in angular 9 app using fullCalendar. A date in the past cannot be selected. I have seen quite a few posts about this in relation to javascript but not Angular/typescript.
I have learnt that to find a current date I can use the below function in Angular:
today: number = Date.now();
I have the below in my ts form validation (doesn't work):
eventDate:['',Validators.required,(c: AbstractControl) => (new Date(c.value).getTime() < Date.now() ? { invalid: true } : null)],
I am aware of the option of using the below fullCalendar functionality, although I want my users to see their previous appointments and so I would like a validator that advises users that a date in the past cannot be booked:
validRange:function(nowDate){
return{
start:nowDate,
}
}
Any help would be very appreciated!
from Angular 9 Typescript fullCalendar Validation for previous date - date in the past cannot be selected
No comments:
Post a Comment