 <p>try this. it works for me.</p> <pre><code> $("#txtPaid").keyup(function () { var val1 = parseInt(document.getElementById('&lt;%=lblGrandTotal.ClientID %&gt;').innerHTML); var val2 = parseInt(document.getElementById('&lt;%=txtPaid.ClientID %&gt;').value); if (val1 != null &amp;&amp; val1.toString() != "NaN" &amp;&amp; val2 != null &amp;&amp; val2.toString() != "NaN") { $("#&lt;%=lblBalance.ClientID %&gt;").html(val1 - val2); } else { $("#&lt;%=lblBalance.ClientID %&gt;").html("0"); } }); </code></pre>