Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"required" validator for p-calendar

There is no required validator available for p-calendar control of PrimeNG:

<p-calendar formControlName="startDateControl" [minDate]="today" showIcon="true"></p-calendar>

Is there any workaround?

like image 554
Debo Avatar asked Oct 20 '25 14:10

Debo


1 Answers

Yes there is. PrimeNG Calendar Docs

Required Attr Calendar

[required]="true"

When present, it specifies that an input field must be filled out before submitting the form.

<p-calendar formControlName="startDateControl" [required]="true" [minDate]="today" showIcon="true"></p-calendar>

You can also specifiy it in reactive form as you've used formControlName.

this.calendarForm = this.fb.group({
   'startDateControl': [null, Validators.required] // <-- Like this
});
like image 144
Sangwin Gawande Avatar answered Oct 22 '25 05:10

Sangwin Gawande



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!