To make this sort of validation to work in all sort of browsers I would recommend reading a bit about regular expressions and use ereg() og eregi() to check the content of each form-field. This is in my opinion the best way to check form fields, and allthough it can seem a bit tough to learn at first it isn't really that hard. Try reading this: http://cyrus.stud.hive.no/pdf/Basic_Syntax_Regular_Expressions.pdf for an introduction to the subject.
There is also a great deal of posts conserning the subject on this board, so you can find good information and tips/examples by searching the forum for validation or something like that.
To check if a field is empty, you can simple use:
if($fieldname && $another_fieldname)
//returns true if the fields above have content
// and false otherwise
Hope this can help...