<input type="text" id="zipCode" />
how can i validate that this is a valid zip code in javascript?
You can match the input against this regex.
/^\d{5}(-\d{4})?(?!-)$/
US zip codes are 5 digits followed by an optional 4 digits.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With