Validate the postcode field by a calculation so that user can only enter 6 or 7 characters:
pc = Substitute ( postcode ; " " ; "" ) ;
Length(pc) = 6 or Length(pc) = 7
Set the field auto-enter calculated value to:
pc = Substitute ( postcode ; " " ; "" );
Length(pc) = 6 ;
Upper( Replace ( pc; 4 ; 0 ; " " ) );
Upper( Replace ( pc; 5 ; 0 ; " " ) )
Uncheck the "Do not replace existing value" of field.
I'm sorry but this is no what i need, what your suggesting is to force users only to be able to enter a set number of digits but the lengh is not hte issue its where the space is that is the issue
Can you give an example of what you want. Chances are that the auto-calc used here can be adjusted to do what you need. Here in the US, the only spaces are between the state abbreviation and the Zip Code (What we call a Postal Code) and those can easily be handled in the layout design rather than the data.
Formats such as XXXX XXX or XXX XXX or XX XXX or X XXX but always with a space at before the third last digit within the UK otherwise it concludes the formatting is incorrect
Then the above validation won't work but assuming codes with digits limited to 0-9 (a small change would accept letters of the alphabet) this expression would add that space before the "Third last digit".
Let ( [ pc = Filter ( self ; 9876543210 ) ; // use Filter ( Upper ( self ) ; "ABCDEFGHIJKLMNOPQRSTUVWXYZ9876543210" ) If codes use letters
L = Length ( pc ) ] ;
If ( L > 7 or L < 4 ; self ; .// don't modify data entry if wrong number of digits are entered you can also set a validation rule to catch this error
Left ( pc ; L - 3 ) & " " & Right ( pc ; 3 )
) // If
) // Let
And be sure to clear the "Do not replace.." check box.
"Formats such as XXXX XXX or XXX XXX or XX XXX or X XXX "
Is your last example correct with just a single letter/digit before the space?
"...Royal Mail introduced postcodes to the United Kingdom between 1959 and 1974. The format of a UK postcode is always one of the following:
- LN NLL
- LLN NLL
- LNN NLL
- LLNN NLL
- LLNL NLL
- LNL NLL
Where L represents a letter, and N a number......." [http://www.postcode-info.co.uk/about-uk-postcodes.html - my emphasis]