Last active
April 22, 2020 17:14
-
-
Save stevensdotb/5bcb74ff0a5a05a3d95a21f391069add 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
/** | |
* Avoid non-numeric characters on input text | |
*/ | |
numberOnly(event) { | |
const value = event.target.value; | |
const lastChar = value.length > 0 ? Number(value[value.length - 1]) : 0 ; | |
const isNaN = char => char !== char; | |
if ( isNaN(lastChar) ) { | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment