<p>Is there a way to run some custom Javascript whenever a client-side ASP.NET validator (<code>RequiredFieldValidator</code>, <code>RangeValidator</code>, etc) is triggered? </p>

<p>Basically, I have a complicated layout that requires I run a custom script whenever a DOM element is shown or hidden. I'm looking for a way to automatically run this script when a validator is displayed. (I'm using validators with <code>Display="dynamic"</code>)</p>

The best solution I've identified for my specific situation is this:
Create a global JS data structure mapping control IDs to a visibility state.
Register the client IDs of the validators (or anything else, for that matter) in this data structure.
Every 250 milliseconds, loop through the global data structure and compare the cached visiblity state with the element's current state. If the states are different, update the cache and run the custom resize script.
This is ugly in lots of ways, and it's only a solution for my specific scenario, not the abstract case where we want to piggyback arbitrary code onto the showing/hiding of a validator. I'd love a better suggestion!