Validating number using javascript
<p>I have a 3 textboxes on a page quantity, price and total . When the quantity and price are entered by the user the total is being calculated directly by using javascript.
Below is the code:</p>

<pre><code>   function quantity(textvalue) {
    var qty = textvalue.value;
    var price = document.getElementById('&lt;%=Price.ClientID %&gt;').value;
    var Total = Math.round(qty * price * 100) / 100;

    document.getElementById('&lt;%=Total.ClientID %&gt;').value = Total;

}

   function Price(textvalue) {
    var price = textvalue.value;
    var qty = document.getElementById('&lt;%=Quantity.ClientID %&gt;').value;
    var Total = Math.round(qty * price * 100) / 100;

    document.getElementById('&lt;%=Total.ClientID %&gt;').value = Total;

}

 &lt;asp:TextBox ID="Quantity" runat="server" onchange="javascript: quantity(this);" CausesValidation="True"&gt;&lt;/asp:TextBox&gt;
      &lt;asp:TextBox ID="Price" runat="server" onchange="javascript: Price(this);"  &gt;&lt;/asp:TextBox&gt;
        &lt;asp:TextBox ID="txtLineItemTotal" runat="server" Width="120px" MaxLength="14" ReadOnly="true"  
        BackColor="Silver" BorderWidth="2px" style="font-weight: 700"&gt;0.00&lt;/asp:TextBox&gt;
</code></pre>

<p>I also need to validate the value calculated in the total textbox and it should not exceed 100000000000.00.</p>

<p>I am using the below function to achieve this </p>

<pre><code>function TotalChanged() {
    var lineitemtotal = document.getElementById('&lt;%=Total.ClientID %&gt;').value;
    alert("entered function");
    if (lineitemtotal &gt;= 100000000000.00) {
        alert("Total cannot exceed 100000000000.00,please re-enter");
    }
    else
        return false;
    }
</code></pre>

<p>And on Page Load </p>

<pre><code> Total.Attributes.Add("onchange", "{return TotalChanged()};");
</code></pre>

<p>But it is not entering the function, please let me know what am I missing...or if I am using the wrong event...trying it for the past 1 day....:(</p>
