Here is another example for form validation. We are using a function to loop through all of the form objects and to take appropriate action if a mandatory field is not completed.
While this version of the example is targeting Acrobat/Reader version 8.1, it also uses the propagate event, which is not actually available in Acrobat/Reader version 8. In practice, if you were targeting the form to version 8.1, then you would remove the propagated exit event and the form will work as intended. The only different is that the error highlighting will remain until the user clicks submit again. The reason I have left the propagated exit event in place is that if you are targeting a higher version of Acrobat/Reader, then you can take advantage of this script.