Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to disable future months in p-calendar?

I want to disable future months and display only current month while selecting in UI, I am using p-calendar.

<p-calendar appendTo="body" class="SharesTblCalendar" name="closeDate" 
            [(ngModel)]="note.closeDate" [monthNavigator]="true" [yearNavigator]="true"
            [yearRange]="yearRange" 
</p-calendar>

this is the code I am using but couldnot resctric it from taking month

like image 867
ramya sriram Avatar asked Nov 04 '25 20:11

ramya sriram


1 Answers

You can use maxDate to restrict calendar

 <p-calendar appendTo="body" class="SharesTblCalendar" name="closeDate" 
            [(ngModel)]="note.closeDate" [monthNavigator]="true" [yearNavigator]="true" 
            [yearRange]="yearRange"  [maxDate]="maxDate"
</p-calendar>


let today = new Date();
let month = today.getMonth();
this.maxDate = new Date();
this.maxDate.setMonth(month);
like image 85
Jeyam Prakash Avatar answered Nov 07 '25 09:11

Jeyam Prakash



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!