Answers for "preventing letters from being placed in an input ts"

0

preventing letters from being placed in an input ts

validateNumber(event) {
    const keyCode = event.keyCode;

    const excludedKeys = [8, 37, 39, 46];

    if (!((keyCode >= 48 && keyCode <= 57) ||
      (keyCode >= 96 && keyCode <= 105) ||
      (excludedKeys.includes(keyCode)))) {
      event.preventDefault();
    }
  }
Posted by: Guest on November-18-2020
0

preventing letters from being placed in an input ts

<input type="password" placeholder="Enter Mobile no" formControlName="mobile_no" (keydown)="validateNumber($event)">
Posted by: Guest on November-18-2020

Code answers related to "preventing letters from being placed in an input ts"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language