Specifically there is a page titled: 'Examples of agents to run before Web users open or save documents'.
The WebQuerySave is one event you could use.
I usually code my button(s) to perform some initial calculations, such as set values to uppercase, trim leading & trailing spaces, etc, then call an agent using @Command([ToolsRunMacro] ; <agent> ) ; If the validation fails in the agent, i update a message field o0n the screen, if the agent is successful I open the next page.