Allow only letters and spaces and capitalise each word
<p>I need to only allow letters to be typed, and I also need to capitalise the first letter of each word using javascript. I have the first bit working on keypress, I want the second working onblur, but I can't get it to work. It works ok if I use it on its own though. I've tried a bunch of things but I must be missing something small, I just can't figure out what it is.</p>

<p>HTML</p>

<pre><code>&lt;tr&gt;
&lt;td&gt;
&lt;input type="text" name="first_names" onkeypress="return isAlfa(event)" onblur="toTitleCase()"&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;input type="text" name="last_names" onkeypress="return isAlfa(event)" onblur="toTitleCase()"&gt;
&lt;/td&gt;
&lt;/tr&gt;
</code></pre>

<p>JAVASCRIPT</p>

<pre><code>function isAlfa(evt) {
    evt = (evt) ? evt : window.event;
    var charCode = (evt.which) ? evt.which : evt.keyCode;
    if (charCode &gt; 32 &amp;&amp; (charCode &lt; 65 || charCode &gt; 90) &amp;&amp; (charCode &lt; 97 || charCode &gt; 122)) {
        return false;
    }
    return true;
}

function toTitleCase(str)
{
    return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
}
</code></pre>

<p>Please assist</p>