How to intercept the onclick event
<p>I'd like to intercept the onclick event of a button (not submit) before the page posts back from the onclick.</p>

<p>I'm having some trouble:</p>

<pre><code>$(document).ready() { function() {
    function validate() { 
        ...
    }

    var oldOnClick = $("input[value=OK]").attr("onclick");
    $("input[value=OK]").attr("onclick", "if(!validate()) { return false; }" + oldOnClick));
});
</code></pre>
