Skip to content

Instantly share code, notes, and snippets.

@yankeyhotel
Created September 10, 2014 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yankeyhotel/44819abd1f4d92511b99 to your computer and use it in GitHub Desktop.
Save yankeyhotel/44819abd1f4d92511b99 to your computer and use it in GitHub Desktop.
Validate Zip Code in Javascript
function isValidZipCode( zipCode ) {
var pattern = new RegExp(/^\d{5}(?:[-\s]\d{4})?$/);
return pattern.test(zipCode);
}
if( !isValidEmailAddress( zipCode ) ) {
/* do stuff here */
}
@yankeyhotel
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment