jquery too much recursion on multiple blur function
<p>I am checking some textboxes on blur, some need to be checked against the same critera so I put these all in one blur function. I have noticed that my page seems slow and in firebug I keep gettin the error <code>too much recursion</code> . </p>

<p>My code is below, it checks the textbox and then sends the ID to another function which adds a class to say if it is valid or not valid.</p>

<pre><code>$('#username, #customerName, #customerTown, #customerCounty, #contactName, #staffFirstname, #staffLastname, #staffTown, #staffCounty').blur(function()
{
   var ID = $(this).attr('id');
       var val = $(this).val();                     
       if(validate(val))
       {
           valid(ID);

       }
       else
       {            
           notValid(ID);
       }

});

function valid(elementID)
{
            $('#'+elementID+'Img').html('&lt;img src="../images/tick.png" alt="Valid" title="Valid" /&gt;');
            $('#' + elementID).addClass('valid');

}

function notValid(elementID)
{
            $('#'+elementID+'Img').html('&lt;img src="../images/cross.png" alt="Not Valid" title="Not Valid" /&gt;');
            $('#' + elementID).removeClass('valid');                    

}

function validate(val)
    {
        var reg = new RegExp ("^([a-zA-Z ]){3,90}$");
        var regTest = reg.test(val); 
        if(regTest)
        {
            return true;
        }
        else
        {
             return false;
        }
}
</code></pre>

<p>Would it be better if I did a seprate <code>blur</code> function for each textbox? Or is there another way? I don't really want to write a blur function for every single textbox.</p>

<p>Any suggestions? Thanks.</p>
