UK postcode imput mask (1 Viewer)

YNWA

Registered User.
Local time
Today, 21:48
Joined
Jun 2, 2009
Messages
905
Hi all,

Anyone know an imput mask for UK postcodes?

I know there is one built it "LL00 0LL"

But this does not work well when enetering a post code with 1 char (eg. L1 or L21).

Does anyone have a simple work around so when a user enters a post code they are all show like this...

L1 5TT
L22 5TT
WA1 5TT
WA17 5TT

Is it possible?

Cheers
Will
 
Last edited:

vbaInet

AWF VIP
Local time
Today, 21:48
Joined
Jan 22, 2010
Messages
26,374
Have a look through the Sample Databases section or Code section. DCrake has a postcode validation db. You might find the input mask for it too.
 

Brianwarnock

Retired
Local time
Today, 21:48
Joined
Jun 2, 2003
Messages
12,701
I am not convinced that it is possible to get a good input mask as the post code design is so naff, an argument I had with one of the designers.

I cant really remember what we used at the charity I worked for , in Liverpool by coincidence, but I think it started L&&&&& then some C but not sure, but as you can see it merely insists on a Letter to start and a minimum of 6 characters or spaces.

Brian
 

John.Woody

Registered User.
Local time
Today, 21:48
Joined
Sep 10, 2001
Messages
354
L1 5TT
L22 5TT
WA1 5TT
WA17 5TT

You missed one W1A 5TT. I don't try and use an input mask, I just force it in to uppercase.
 

Simon_MT

Registered User.
Local time
Today, 21:48
Joined
Feb 26, 2007
Messages
2,177
These are the Input Masks I use:

Countries Postcodes Mask >L0\ 0LL;0; >L00\ 0LL;0; >LL0\ 0LL;0; >LL00\ 0LL;0; >LL0L\ 0LL;0; >L0L\ 0LL;0;
These are stored in a Table and put on a Dialog Form and after selection and on another control the Input Mask is set ready for input of the actual postcode.

Simon
 

vbaInet

AWF VIP
Local time
Today, 21:48
Joined
Jan 22, 2010
Messages
26,374
Complex Regular expressions would be the best tool to employ for postcode validation. If I ever get the time I will write one but it would be time consuming so I may not. But like I said, have a look in the Samples Database section or search the Code Repository, there's a UK postcode validation routine there.
 

YNWA

Registered User.
Local time
Today, 21:48
Joined
Jun 2, 2009
Messages
905
Thanks for all your answers.

Although there great tools, all I really want is the post code when entered to be stored in the format of first half space second half.

Eg. L225TT = L22 5TT

I just need the space.
 

Brianwarnock

Retired
Local time
Today, 21:48
Joined
Jun 2, 2003
Messages
12,701
As I said earlier , due to the poor design of the postcode there is no logical way to do this in a mask, the only way to do it would be by code the 3 right characters then a space then the rest as the left most characters.

Brian
 

Simon_MT

Registered User.
Local time
Today, 21:48
Joined
Feb 26, 2007
Messages
2,177
Brian,

You are quite correct it is a bit of a pain.

First you have to select the Country inserts an Input Mask if there is only one format. Even the States have two because the need to refine ZIP codes, Australia has prefixes WA SA QLD NSW. If only each country had only one Zip or Postcode format.

Simon
Simon
 

Brianwarnock

Retired
Local time
Today, 21:48
Joined
Jun 2, 2003
Messages
12,701
Well as i told the fool I argued with ours, ie the UK, could easily have just had 2 letters and 2 numbers before the space in all cases, nobody in L1 would have been any the wiser if from the start it had been LV11, we will avoid the leading 0 scenario. Yeah I know that there used to be in all probability an old code of Liverpool 11, but we all had to learn new things when the post codes came in.

Brian
 

Lonemascot

Registered User.
Local time
Today, 13:48
Joined
Apr 2, 2013
Messages
14
Ive just used >LAaC\ 0LL. The 2nd and 3rd characters can be either letter or digit with the 4th being a character or space. This can produce a few dodgy results due to input error but at least you can't write a bunch of crap in the field which is mainly what i use it to stop happening.

Let me stress, you can still input an invalid UK postcode but it does allow all of the UK formats:
LL0L 0LL
L0L 0LL
L0 0LL (this one requires a double space) N1--3BN
L00 0LL
LL0 0LL
LL00 0LL
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 21:48
Joined
Sep 12, 2006
Messages
15,656
there are only 122 (from memory) left portions of a post code - so you could always add a specific test to ensure that part of the post code is genuine.
 

SteveH2508

Registered User.
Local time
Today, 21:48
Joined
Feb 22, 2011
Messages
75
Just to add - there are also characters which are not allowed in the second part of the UK post code.

I do not think you can input mask it properly - I think VBA is probably the only way to go.
 

Users who are viewing this thread

Top Bottom