Last active
August 3, 2021 20:54
-
-
Save ssdev-95/4c58154218cc66aa53049347bda042ba to your computer and use it in GitHub Desktop.
Input Validation
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
| import { ChangeEvent } from 'react'; | |
| function handleKeyUp(e: ChangeEvent<HTMLInputElement>) { | |
| e.currentTarget.maxLength = 8; | |
| let value = e.currentTarget.value; | |
| value = value.replace(/\D/g, ""); | |
| setNewZip(value) | |
| e.currentTarget.value = value; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment