Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 230849

ionChange not showing the expected behavior

$
0
0

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.


Viewing all articles
Browse latest Browse all 230849

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>