What is the required format when capturing a postal code?

What is the required format when capturing a postal code?

The postcode is a combination of between five and seven alphanumeric characters which define four different levels of geographic unit.

It is part of a coding system created and used by the Royal Mail across the United Kingdom for sorting mail. The postcodes are an abbreviated form of address, which enable a group of delivery points (a delivery point being a property or a post box) to be specifically identified.

Note!
      Full valid postcodes can be located at the Royal Mail Postcode finder website: http://www.royalmail.com/postcode-finder.

Each postcode consists of two parts. The first part is the outward postcode, or outcode. This is separated by a single space from the second part, which is the inward postcode, or incode.

Important!
      It is pivotal to ensure that a space has been inserted between the outward and inward part of the postcode.
      For example: EC1Y 8SY