What's Here?
- Members: 244,258
- Replies: 693,057
- Topics: 113,147
- Snippets: 3,863
- Tutorials: 935
- Total Online: 1,283
- Members: 95
- Guests: 1,188
|
Validates a zip code based on both US zip code schemes: 12345-1234 or 12345
|
Submitted By: skyhawk133
|
|
Rating:

|
|
Views: 23,319 |
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
|