javascript doesn't immediatly enable my button
<p>I use VS2010,C# for ASP.NET development, I've written a small Javascript function that enables an initially disabled button only after user inputs a phrase in a text box (this text box should not be empty), it works fine but there is a small problem, button is not enabled exactly when user types words, he should press tab or click on the screen so that button gets enabled! here is my JS function:</p>

<pre><code>       &lt;script type="text/javascript" &gt;
       function onWeightChange() {
           document.getElementById('btnFinish').disabled = true;
           document.getElementById('btnConfirmQuestion').disabled = true;
           if (document.getElementById('txtWeight').value != "") {
               document.getElementById('btnFinish').disabled = false;
               document.getElementById('btnConfirmQuestion').disabled = false;
           }
       }
&lt;/script&gt;
</code></pre>

<p>and I call my JS in codebehind in the following way:</p>

<pre><code>            txtWeight.Attributes.Add("onchange", "return onWeightChange();");
</code></pre>

<p>what is going wrong here? I want my buttons to get enabled right after text is entered in textbox, and there should not be any need to change focus from textbox</p>

<p>thanks</p>
