Last active
January 12, 2019 23:41
-
-
Save saniyusuf/12893bed87f7fbc2b98f583360f032de to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment