JavaScript Zip Code Validation

A 5-digit United States Zip Code can be validated in JavaScript with a regular expression:

/^\d{5}$/.test('84601')

This specifies that the string being tested must begin and end as a digit with a length of five.

Leave a Reply