Answers for "how to restrict alphabets in input field in angular"

0

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>
Posted by: Guest on April-25-2021

Code answers related to "how to restrict alphabets in input field in angular"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language