How to handle the invalid date in Prime ng Calendar

Discussão em 'Angular' iniciado por Boopathi Vkl, Abril 4, 2025.

  1. Boopathi Vkl

    Boopathi Vkl Guest

    After selecting the date from calendar picker, when editing/input the dates, need to handle some validation.

    Below is the scenario:

    Selected april 30 2025 from the picker. Edited the date to 31st april, which is not a valid date. When doing this the value should be automatically change to May 1. Is there any way to handle in Prime NG calendar or any customization needed.

    <p-calendar [showOnFocus]="false" [(ngModel)]="newExpirationDate"(ngModelChange)="NewrowExpirationDateChange($event)" [showIcon]="true"


    placeholder="mm/dd/yyyy">

    NewrowExpirationDateChange(event: any): void {
    const formattedDate = this.datePipe.transform(event, 'MM/dd/yyyy');
    //need to handle the invalid date logic here
    }

    Continue reading...

Compartilhe esta Página