Satyendra Mishra Satyendra Mishra - 1 month ago 4x
Javascript Question

Zipcode validation for US

Can any one tell me how can i validate zipcode for US using regular expression.

I used below expression for validation

var us_postcode_regular = /^([0-9]{5})(?:[-\s]*([0-9]{4}))?$/;

However it is not able to validate all 00000 or 11111 or similar numbers.

and how can i validate the incorrect zipcode like the five digits which are not the part of US zipcode.

if(ctype_digit($zip) && strlen($zip) == 5){ echo 'US Zip Code'; }