What's Here?
- Members: 148,616
- Replies: 504,675
- Topics: 79,460
- Snippets: 2,659
- Tutorials: 705
- Total Online: 1,283
- Members: 76
- Guests: 1,207
|
Validates a zip code based on both US zip code schemes: 12345-1234 or 12345
|
Submitted By: skyhawk133
|
|
Rating:

|
|
Views: 19,031 |
Language: JavaScript
|
|
Last Modified: February 28, 2005 |
Instructions: Call using isZip(form.field.value);
Returns boolean |
Snippet
function isZip(s)
{
// Check for correct zip code
reZip = new RegExp(/(^\d{5}$)|(^\d{5}-\d{4}$)/);
if (!reZip.test(s)) {
alert("Zip Code Is Not Valid");
return false;
}
return true;
}
Copy & Paste
|
|
|
Be Social
Programming
Web Development
Reference Sheets
Bye Bye Ads
Monthly Drawing
Top Contributors
Top 10 Kudos This Month
|