This seems like an incredibly verbose way of validating a UK postcode. Why not just use a regular expression?
I just wrote this one and it seems to work OK:
It takes into account central London postcodes such as WC1H 9EF, which yours doesn't at the moment, and it works for postcodes with or without the space.
Also, even if it's a "valid" postcode, it doesn't mean it exists. If you really want to be accurate, you should compare it against a database of existing UK postcodes, which you need to pay for. However, limited versions (only the first part) exist, e.g. http://www.easypeasy.com/guides/article.php?article=64