When inserting the date by typing in the input in the format dd / mm / yyyy
the field becomes invalid making my form invalid not allowing to save the record.
But if I use datePicker and insert the date the field becomes valid.
Even though I use datePicker and after inserting the value in the input with datePicker copying the value and pasting in the input is getting invalid ...
The date is only valid if I use datePicker ... I can not insert date writing in dd / mm / yyyy
format.
The datePicker is inserting date in the input format with dd / mm / yyyy
, I typed the date in the input in the format dd / mm / yyyy
but the date is considered invalid.
The problem only occurs when I type the date in the input, the date is only valid if I insert the date in the input through the datePicker.
myform.ts:
this.formBuilder.group({
date: [''],
});
........................
myform.html:
<mat-form-field fxFlex>
<input matInput [matDatepicker]="DatePicker" formControlName="date" name="date" placeholder="Date">
<mat-datepicker-toggle matSuffix [for]="DatePicker"></mat-datepicker-toggle>
<mat-datepicker touchUi="true" #DatePicker></mat-datepicker>
</mat-form-field>
Since my form is very large, I've just put what is causing me a problem when saving the record.