Toni Michel Caubet
Toni Michel Caubet

Reputation: 20183

Can a zipcode input be validated worldwide?

I found this regex

var zipCodePattern = /^\d{5}$|^\d{5}-\d{4}$/;

That won't validate: 12345, but it does validate 07179. I need to be sure that it would work worldwide, would it? If not, does it exist?

Upvotes: 0

Views: 885

Answers (1)

sgowd
sgowd

Reputation: 2262

No, in some countries(India, for eg.), the Zip Code is of 6 digits and in some others, it might be entirely different with spaces also. Your expression should support that too.

Upvotes: 4

Related Questions