Bryan, the recommended way in XPages for validation is to use a validator, You write much less code, you can selectively control when to validate fields, you can separate different checks from each other.
Check my thoughts about validation. In a nutshell:
- Validation in code (a button, the submit event etc.) is a typical way validation is done. Being the prevalent way doesn't make it right . You need to roll your own notification mechanism (like updating a label) and tend to tie your validation into the UI. Also when you remove a field the validation routine is likely to break. Last not least: you have a hard time documenting what gets validated and why. (You see where I'm going with that)
- Validators are defined together with a field and open a series of possibilities. XPages offers 9 different validators.
- You can write JavaScript, regular expressions, check for data types or roll your very own. All you can do in a button/event code you can do in a validator. Since the validators themselves don't interact with the UI the designer can decide how to surface the messages without changes to the validation code. When you remove a field all its validation code goes with it, so maintenance gets much easier. Last not least: you can run an XSLT report against your XPages source and render a report that shows a field with all the defined validators, which makes documentation easier.
- Form Validation are the @Formulas defined in your classic Notes form. They only fire when you have specified "Run form validation" as "On Save" or "Both". Typically you would use those when upgrading existing applications.