Users should only be able to enter valid years (e.g., 2020) in the Purchase Year form field. An error message should display if an invalid number or text is entered.
While many suggest using a datepicker, I specifically need users to only input the year value. Can anyone assist me in writing the necessary code for this?
<mat-form-field>
<mat-label>Purchase Year<mat-icon class="required">star_rate</mat-icon></mat-label>
<input matInput formControlName="PurchaseYear" placeholder="Purchase Year">
</mat-form-field>