I need assistance with displaying a text field based on age validation. The requirement is to show the input field only if the age is less than 18.
Below is the code snippet I am currently working with:
<form [formGroup]="form">
<mat-form-field>
<input matInput [matDatepicker]="picker" placeholder="Choose a date"
formControlName="pickerCtl">
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker #picker></mat-datepicker>
</mat-form-field>
<mat-form-field>
<mat-label>Guardian Name</mat-label>
<input matInput formControlName="guardianName" class="form-control" placeholder="Guardian Name">
<span class="fa fa-lock lock_field"></span>
</mat-form-field>
<mat-form-field>
<mat-label>Guardian Contact No</mat-label>
<input matInput formControlName="guardianContactNo" class="form-control" placeholder="Guardian Contact No">
<span class="fa fa-lock lock_field"></span>
</mat-form-field>
Currently, I have successfully implemented the datepicker to allow selection from 1900 until the day before today's date.
Below is the TypeScript code for the date range:
minDate = new Date(1900, 0, 1);
maxDate = new Date(new Date().setDate(new Date().getDate()-1))
You can view the project on Stackblitz.