Created
September 10, 2014 15:19
-
-
Save yankeyhotel/44819abd1f4d92511b99 to your computer and use it in GitHub Desktop.
Validate Zip Code in Javascript
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
function isValidZipCode( zipCode ) { | |
var pattern = new RegExp(/^\d{5}(?:[-\s]\d{4})?$/); | |
return pattern.test(zipCode); | |
} | |
if( !isValidEmailAddress( zipCode ) ) { | |
/* do stuff here */ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Via: http://stackoverflow.com/questions/2577236/regex-for-zip-code