ionic framework - Inoic 3, Android: How to only allow number input field? -


i have input field this:

.html file:

<ion-input formcontrolname="codepin"             type="tel"             pattern="[0-9]*"             class="itemborder"             placeholder="only number"             maxlength="4"             style="-webkit-text-security:disc"            [(ngmodel)]="codepin" (keydown)="isvalidnumber($event)"> </ion-input> 

.ts file:

isvalidnumber(event) {     //return /\d|backspace/.test(event.key);     if ([8, 13, 27, 37, 38, 39, 40].indexof(event.keycode) > -1) {         // backspace, enter, escape, arrows         return true;     } else if (event.keycode >= 48 && event.keycode <= 57) {         // numbers 0 9         return true;     } else if (event.keycode >= 96 && event.keycode <= 105) {         // numpad number         return true;     }     return false; } 

the problem is, runs ok in ionic serve's lab, ios, not working in android. please explain me how fix this. thanks.


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

php - Cannot override Laravel Spark authentication with own implementation -

Qt QGraphicsScene is not accessable from QGraphicsView (on Qt 5.6.1) -