I have this ion-input here:
<ion-input type="text" [(ngModel)]="info.date" (ionChange)="handleDate()" ></ion-input>
and I was trying to limit user entry to just numbers and “/” so I did this:
handleDate() {
if (!/^[0-9/]+$/.test(this.info.date)) {
this.info.date = this.info.date(0, this.info.date - 1);
}
}
Expected behavior : every time a user enters something other than numbers or “/” it doesn’t get displayed.
Actual behavior : the first invalid character gets erased as expected but the rest still shows up. For example,
if I enter ssss … the first s is handled successfully but the rest still shows up.