You can use the suggestion of downloading all the UK Post Codes to your database. However, you'll have to stay on top of it as new codes are added later. I'm sure there's an automatic free service out there that will do this for you, but that would be very advanced programming for you.
If you want to just validate the pattern, I found this example. It will not only validate the pattern, but also correct for common typo errors.
If you do use this code, you'll still have to call it at the correct time. That could be when the user leaves the textbox after entering the code, or when they are trying to save the record, or move to another record (automatic save).
Good luck