material icon indicating copy to clipboard operation
material copied to clipboard

mat-datepicker -Changing Date when Manually inserted

Open Nimzi-Git opened this issue 9 years ago • 2 comments

Code Snippet: <input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="picker" id="startdate" class="form-control" name="startdate" formControlName="startdate" type="text"> <mat-datepicker-toggle matSuffix [for]="picker" ></mat-datepicker-toggle> <mat-datepicker #picker></mat-datepicker>

whenever I insert dates manually example 23/32/2017(dd/mm/yyyy) in my angular 4 application -the date control is sending Fri Aug 02 2019 00:00:00 GMT+0100 (GMT Standard Time) rather than throwing validation problem as 32 cannot be considered as a month. I have 2 questions here -

  1. How can I restrict the datepicker module to change the dates in the background(it should be same as what the user is entering)?
  2. whenever user enters 2 digits in the year field, datepicker amend the year value with the corresponding century value. how can we restrict the user to insert the complete year value?

All the above question is related to Angular 2/4.

Thanks

Nimzi-Git avatar Oct 20 '17 10:10 Nimzi-Git

I have the same problem. Whenever I insert manually date with european format (dd/mm/yyyy) input is displaying like invalid with red line below.

oleksandr-tkach avatar Oct 30 '17 16:10 oleksandr-tkach

Please submit Angular Material questions here and issues here. This repo is for AngularJS Material.

Splaktar avatar Dec 13 '17 08:12 Splaktar