Answers for "preventing +,-,e from input ts"

0

preventing +,-,e from input ts

<input(keyup)="_keyUp($event)">
Posted by: Guest on November-18-2020
0

preventing +,-,e from input ts

_keyUp(event: any) {
    const pattern = /[0-9\+\-\ ]/;
    let inputChar = String.fromCharCode(event.key);

    if (!pattern.test(inputChar)) {
      // invalid character, prevent input
      event.preventDefault();
    }
}
Posted by: Guest on November-18-2020

Code answers related to "preventing +,-,e from input ts"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language