preventing 2b 2c 2ce from input ts

Solutions on MaxInterview for preventing 2b 2c 2ce from input ts by the best coders in the world

showing results for - "preventing 2b 2c 2ce from input ts"
Henri
17 Feb 2019
1<input(keyup)="_keyUp($event)">
2
Jarod
24 Jul 2016
1_keyUp(event: any) {
2    const pattern = /[0-9\+\-\ ]/;
3    let inputChar = String.fromCharCode(event.key);
4
5    if (!pattern.test(inputChar)) {
6      // invalid character, prevent input
7      event.preventDefault();
8    }
9}
10