0x00 Posted October 18, 2007 Share Posted October 18, 2007 Hi, i'm after some information on validating address's from everywhere, probably postcode and telephone numbers are most important. Could someone show me a list of how each country formats theirs, even better for an example with php n regex. I've done some googling, but it left me dangling with many pay services which look up for you, but i don't really need that level so... Cheers in advance!!! Quote Link to comment https://forums.phpfreaks.com/topic/73819-address-form-validation/ Share on other sites More sharing options...
Psycho Posted October 18, 2007 Share Posted October 18, 2007 Are you looking to validate that the address is properly formatted or that it is a valid address. If the latter you will need to find APIs for each country you want to incorporate. If the former, then you could just look for existing functions for each country individually. Are you having users enter the entire address into a textarea? typically forrms require users to enter address data into discrete fields. Quote Link to comment https://forums.phpfreaks.com/topic/73819-address-form-validation/#findComment-372500 Share on other sites More sharing options...
0x00 Posted October 18, 2007 Author Share Posted October 18, 2007 In essence it's really postcodes and phone numbers. I found this which is a good example for GB (http://www.ml-consult.co.uk/foxst-39.htm), but am searching for others. I've also found some references to the formats for other countries, whilst wiki has come up trumps for dialing codes and number formats. I'm just looking for the esay option, but quite happy to do it, prolly post it on 'PHP Freaks Forums > PHP and MySQL > FAQ/Code Snippet Repository' when I finish... Quote Link to comment https://forums.phpfreaks.com/topic/73819-address-form-validation/#findComment-372526 Share on other sites More sharing options...
esukf Posted October 18, 2007 Share Posted October 18, 2007 Try searching http://regexlib.com for validation of postcode/ phone numbers for the countries you want. Quote Link to comment https://forums.phpfreaks.com/topic/73819-address-form-validation/#findComment-372553 Share on other sites More sharing options...
0x00 Posted October 18, 2007 Author Share Posted October 18, 2007 Oh yes... there's some good stuff there, mmm what's the expression? Buzzin! Quote Link to comment https://forums.phpfreaks.com/topic/73819-address-form-validation/#findComment-372568 Share on other sites More sharing options...
0x00 Posted October 20, 2007 Author Share Posted October 20, 2007 Can anyone tell me what characters are valid for the second set of characters in the 'outward code' section of a London postcode? To illustrate, this is a typical UK postcode: SW1 1ZZ Here is the postcode for 10 Downing Street: SW1A 2AA As you can see there's an extra 'A' in the first section, i've also found 'B' (WC2B ***) in some case's. However I can't find a definitive list of valid characters, can you? Here's what my regex look's like so far: if(preg_match("/^[A-IK-PR-UWYZ]{1}[A-HK-Y]{0,1}[0-9]{1,2}[A-Z]{0,1} {1}[0-9]{1}[ABD-HJLNP-UW-Z]{2}$/",$e)) { $res = "Valid"; } As you can see i've used A-Z, but from some checklists i've got it validates invalid codes, such as 'GB7Z 1HQ'. Also note that this currently only handles uppercase characters! Quote Link to comment https://forums.phpfreaks.com/topic/73819-address-form-validation/#findComment-374073 Share on other sites More sharing options...
esukf Posted October 20, 2007 Share Posted October 20, 2007 From http://en.wikipedia.org/wiki/UK_postcodes (GIR 0AA|[A-PR-UWYZ]([0-9]{1,2}|([A-HK-Y][0-9]|[A-HK-Y][0-9]([0-9]|[ABEHMNPRV-Y]))|[0-9][A-HJKS-UW]) [0-9][ABD-HJLNP-UW-Z]{2}) Quote Link to comment https://forums.phpfreaks.com/topic/73819-address-form-validation/#findComment-374130 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.