Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

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();
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #preventing #input #ts
ADD COMMENT
Topic
Name
1+1 =