kolesoffac

filterNumber

Apr 10th, 2020
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     protected filterNumber(e: KeyboardEvent, type: ColumnType): void {
  2.         if (type === ColumnType.number) {
  3.             const key = e.key;
  4.  
  5.             if (key.length === 1 || e.code === 'KeyV' && e.ctrlKey) {
  6.                 if (/[^0-9]/.test(key) && !['.', ',', '-'].includes(key)) {
  7.                     return e.preventDefault();
  8.                 }
  9.             }
  10.         }
  11.     }
Advertisement
Add Comment
Please, Sign In to add comment