How to combine an initial page loop function with a keyup function?
<p>I am using jQuery 1.6.2</p>

<p>When my page loads, I run a loop that finds input fields, calculates their needed size, and resizes them.  Here's the function:</p>

<pre><code>// MINIMIZE TEXT FIELDS ON LOAD
$(":text").each(function() {
    var MyString = $(this).val();
    var MyMax = $(this).attr("maxlength");
    var MySize = minimizeText(MyString, MyMax);
    $(this).attr("size", MySize);
});
</code></pre>

<p>The loop accesses this function:</p>

<pre><code>var minimizeText = function minimizeText(MyString, MyMax) {
var MyLength = MyString.length;
var MySize = MyLength + 5;
if (MySize &lt; MyMax &amp;&amp; MySize &lt; 50) {
    return MySize;
} else if (MyMax &gt; 50 ) {
    return 50;
} else {
    return MyMax;
}
}
</code></pre>

<p>If the user changes the text in the input field, the size is recalculated to fit the text in the field.</p>

<pre><code>// MINIMIZE TEXT FIELDS ON KEYUP
$(":text").keyup(function() {
    var MyString = $(this).val();
    var MyMax = $(this).attr("maxlength");
    var MySize = minimizeText(MyString, MyMax);
    $(this).attr("size", MySize);
});
</code></pre>

<p>Both of these work perfectly well.  My goal here is to condense this code and still make it readable.  My question is how can I combine these two so that the text field are checked on load as well as on keyup?</p>
