Is there a pseudo code to verify the address or phone number in the UK?

Do you have pseudo code to check the fields for the following items in the UK? I am from the USA, therefore I only know those who are now in the USA.

  • Address Line 1
  • Phone number
  • Mobile number (if they have a special rule for this, which they may not use)
  • Postal code
+6
phone-number validation street-address
source share
6 answers

Address bar 1, if you want to verify that the user has entered an arbitrary form, you are likely to get in touch. There is tremendous variability. You can use the PostCode address file (see below) to help,

Typically, if you need a β€œstandard” address, UK-targeted websites ask for a zip code, and then prompt the user to select the correct address from all the addresses in that zip code

Phone and mobile numbers. See here http://en.wikipedia.org/wiki/Telephone_numbers_in_the_United_Kingdom . A script to test these (in several languages) can be found here: http://www.braemoor.co.uk/software/telnumbers.shtml

Zip code format: http://en.wikipedia.org/wiki/UK_postcodes (contains a regular expression for validation and refers to a zip code address file that lists valid addresses)

+5
source share

Address bar 1 can be almost any. Not always house numbers.

Phone numbers: the length of the area code changes. I would not like to swear whether the full length is constant, but I suspect that it is always at least 10 digits. Usually mobile numbers (IMEs) start from 07, while landlines start from 01 or 02. Special numbers (toll free, local tariff, etc.) usually start from 08. I will try to find a link for this. (EDIT: Again, there is a good Wikipedia article .)

Wikipedia has a good article on UK postal codes , including regular expressions for them.

+4
source share

Perl has a Number :: Phone module that can handle UK phone numbers. Royal Mail has services for checking addresses and clearing the list.

+3
source share

For UK phone numbers, the best option (unfortunately) is probably to download number plans from Ofcom (they are Excel spreadsheets with all relevant number ranges, divided by area codes, "geographic numbers", personal numbers, mobile numbers, various service numbers , various payment digits, and also have a comparison from the range of numbers to the operator (the latter is probably NOT something you need).

+1
source share

As always with this question, do not get hung up on excessive checking. Check that the most likely highly distorted inputs then move on. Trying to keep track of which prefixes and phone number lengths are used in any particular region is a huge waste of your time. Providing a few possibly correctable errors is better than losing customers by telling them that they are "invalid."

(The closest to the standard addressing format that you receive in the UK is the zip code plus house number. Even then, there are always exceptions.)

+1
source share

I started the code (or at least a bunch of RegEx templates) for checking out Django forms for GB phone numbers here .
With a basic explanation here .

0
source share

All Articles