I would suggest using Javascript to validate the form, and then once the form has been sent validate it again using php.
Javascript validation is easy, just google for "Javascript Form Validation" and pleanty of examples appear.
The reason you must validate again using Php is because user's can disable javascript, so you shouldn't rely on users browsers to validate the form. It makes it easier for users, but it shouldn't replace your normal validation.
http://www.w3schools.com/js/js_form_validation.asp
That's the example I learned off.