Retrieve value of element on dom on page reload
<p>I have the following JavaScript function which is used to keep users from inundating our server with Ajax requests:</p>

<pre><code>var validateZip = function () {

    var lastSuccessful = parseInt(jQuery('#mailingZip').val(), 10);

    return {
        validate: function(zip) {
            var is5DigitNumber = /^\d{5}$/;
            if (is5DigitNumber.test(zip) && lastSuccessful !== zip) {
                lastSuccessful = zip;
                return true;
            } else {
                return false;
            }
        }
}();
</code></pre>

<p>This page is reloaded if users input a bad zip code or other errors appear on the form.  However since the dom hasn't loaded yet, I always pull NaN from that field.</p>

<p>Placing it in the on document ready for jQuery means that I can't call the function directly.  </p>

<p>How can I modify my scope such that the lastSuccessful will remain "private" and get the value once the dom is ready?</p>
