how to restrict alphabets in input field in angular code example
Example: how to restrict alphabets in input field in angular
phoneKeyDown(e){
const keyCode = e.keyCode;
if (( (e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) && e.keyCode !=8) {
e.preventDefault();
}
}
// IN HTML
<ion-input [(ngModel)]="phone" id="phone" formControlName="phone" placeholder="Enter Telephone Number" (keydown)="phoneKeyUp($event)" ></ion-input>