Skip to content

Instantly share code, notes, and snippets.

@saniyusuf
Last active January 12, 2019 23:41
Show Gist options
  • Save saniyusuf/12893bed87f7fbc2b98f583360f032de to your computer and use it in GitHub Desktop.
Save saniyusuf/12893bed87f7fbc2b98f583360f032de to your computer and use it in GitHub Desktop.

Revisions

  1. saniyusuf revised this gist Jan 12, 2019. 1 changed file with 12 additions and 5 deletions.
    17 changes: 12 additions & 5 deletions input type hack
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,12 @@
    <input type="text"

    (paste)="onPaste($event)"
    (keypress)="onKeyboardEvent($event)"
    >
    <input
    type="text"
    (keypress)="onKeyboardEvent($event)">


    onKeyboardEvent(evt: KeyboardEvent) {
    const charCode = (evt.which) ? evt.which : evt.keyCode;
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
    return false;
    }
    return true;
    }
  2. saniyusuf created this gist Jan 12, 2019.
    5 changes: 5 additions & 0 deletions input type hack
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    <input type="text"

    (paste)="onPaste($event)"
    (keypress)="onKeyboardEvent($event)"
    >