Jump to content

What will be validation for Zip code ?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
eluminoustech

eluminoustech

    Newbie

  • Members
  • Pip
  • 5 posts
Hello Friends,
Here is a post for Zip code Validation

Zip code : Zip code should be atleast 3 & atmost 10 charcters only , should be alphanumeric & should accept dash(-).

Golden Regards,
Eluminous Support Team
eLuminous Technologies

#2
Guest_Jordan_*

Guest_Jordan_*
  • Guests
Here is a regular expression to match 12342-1234 or just 12342 in PHP:
/^([0-9]{5})(-[0-9]{4})?$/i

To determine if a valid zip code exists:

if(preg_match("/^([0-9]{5})(-[0-9]{4})?$/i",$zip_code)) {
    // Match
}

From: USA's Zip Code Validation in PHP