here is an email validation code tutorial

Best thing is to go through the code and post snippets that you don't understand