The Dead Man
The Dead Man

Reputation: 5566

How can I disable past dates in angular p-calendar?

I am using p-calendar

I would like all past dates to be disabled

here is what I have :

 <p-calendar formControlName="date" [inline]="true" tabindex="0" [disabledDates]="invalidDates" [disabledDays]="[0,6]"></p-calendar>

This is not working, what do I need to change to get the result I want ?

Upvotes: 9

Views: 11993

Answers (1)

user184994
user184994

Reputation: 18281

The calendar has a minDate input. Just set it to the current date, that way it cannot be lower than today.

In the code:

minimumDate = new Date();

In the template:

<p-calendar formControlName="date" [inline]="true" [minDate]="minimumDate" tabindex="0" [disabledDates]="invalidDates" [disabledDays]="[0,6]"></p-calendar>

Upvotes: 15

Related Questions