I've implemented the ng-pick-datetime package for handling date selection and display. By using
dateTimeAdapter.setLocale('en-IN')
in the constructor, I have successfully changed the date format to DD/MM/YYYY
. However, I'm facing an issue where even though the calendar picker displays dates in the correct format, manually typing a date such as 03/28/2019
is still accepted. I want to restrict input to only accept the DD/MM/YYYY
format whether it's typed or selected from the calendar. Can someone help me with this?
Code:
<input (ngModelChange)="onChangeDate($event)" [(ngModel)]="dob" name="date" [owlDateTimeTrigger]="dt1" [owlDateTime]="dt1" required>
<owl-date-time class="" [pickerType]="'calendar'" [startView]="'multi-years'" #dt1></owl-date-time>
import { DateTimeAdapter } from 'ng-pick-datetime';
constructor(dateTimeAdapter: DateTimeAdapter<any>){dateTimeAdapter.setLocale('en-IN');}