Created
January 7, 2021 11:17
-
-
Save aderbas/63ac49f6f1ad40a0b1e754dd964a85da to your computer and use it in GitHub Desktop.
This file contains 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
/** | |
* only number field filter | |
*/ | |
const keyRange = [...Array(11).keys()].map(x => x + 48); | |
export const onlyNumber = (e) => { | |
if(-1 === keyRange.indexOf(e.which)){ | |
e.preventDefault(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment