how to restrict alphabets in input field in angular

Solutions on MaxInterview for how to restrict alphabets in input field in angular by the best coders in the world

showing results for - "how to restrict alphabets in input field in angular"
Oscar
17 Nov 2020
1phoneKeyDown(e){
2	 
3		const keyCode = e.keyCode;  
4		if (( (e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) && e.keyCode !=8) {
5			e.preventDefault();
6		} 	  
7}
8
9// IN HTML
10<ion-input [(ngModel)]="phone" id="phone" formControlName="phone"  placeholder="Enter Telephone Number" (keydown)="phoneKeyUp($event)"  ></ion-input>
similar questions