jQuery limit plugin concerns
<p>This question is in reference to <a href="http://unwrongest.com/projects/limit/" rel="nofollow">this jQuery limit plugin</a>. Here's the source:</p>

<pre><code>(function($){ 
    $.fn.extend({  
        limit: function(limit,element) {
            var interval, f;
            var self = $(this);

            $(this).focus(function(){
                interval = window.setInterval(substring,100);
            });
            $(this).blur(function(){
                clearInterval(interval);
                substring();
            });

            substringFunction = "function substring(){ var val = $(self).val();var length = val.length;if(length &gt; limit){$(self).val($(self).val().substring(0,limit));}";

            if(typeof element != 'undefined')
                substringFunction += "if($(element).html() != limit-length){$(element).html((limit-length&lt;=0)?'0':limit-length);}"

            substringFunction += "}";
            eval(substringFunction);
            substring();            
        } 
    }); 
})(jQuery);
</code></pre>

<p>Now I may just be nitpicking here... but maybe I'm missing something. Here are my questions/concerns:</p>

<p>1) What is the purpose of creating the substring function in a string and then <code>eval</code>'ing it? Looking through, it seems like the extension would work perfectly fine if the function was initialized normally.</p>

<p>2) I don't like that it uses a <code>setInterval</code> to execute the substring function. Wouldn't a <code>keypress</code> or similar event be the better and more logical way to do this? Also, I believe this to be the cause of (or at least enabling) the 'flickering text' bug that is referenced in the <a href="http://unwrongest.com/projects/limit/" rel="nofollow">v1.2 change log</a> (No, it isn't fixed).</p>

<p>3) Why is the variable <code>f</code> initialized? It is never used or referenced.</p>

<p>4) Also, this isn't a chainable method, and as a jQuery extension, it should be. I'm not too familiar with writing jQuery extensions, but this can be accomplished by <code>return this;</code> at the end of the method, correct?</p>

<p>It seems like this is just a case of poor programming, but I'd like to get an outside opinion.</p>
