I develop a function for multiple on key up its work fine. For that purpose I have three textbox and call on css class this function. When I enter value in textbox1 and Textbox2 its give answer in Texbox3 .it’s give correct answer .problem is that when we multiple value once time then we empty now these textboxes and Texbox3 value show 1 but there are no value in textbox1 and textbox2 but its give 0 .
I want its show value 0 when there are no value in textboxes1 and textboxes2.
Following my code and textboxes.
$(function () {
$(".toCalculate").change(function () {
$(".toCalculate").keyup(function () {
var total = 1;
$(".toCalculate").each(function (index, item) {
temp = parseFloat($(item).val());
if (isNaN(temp))
temp = 1
total = total * temp;
});
$(".total").val(total);
});
});
});
Textboxes
<td class="style18">
<asp:TextBox ID="TextBox1" runat="server"
onkeypress="return AllowOnlyNumbers(this,event);"
CssClass="toCalculate" Height="16px" Width="117px" MaxLength="10" ></asp:TextBox>
</td>
<td class="style19">
<asp:TextBox ID="TextBox1" runat="server"
onkeypress="return AllowOnlyNumbers(this,event);"
CssClass="toCalculate" Height="16px" Width="105px" MaxLength="10"></asp:TextBox>
</td>
<td class="style22">
<asp:TextBox ID="total" runat="server"
onkeypress="return AllowOnlyNumbers(this,event);"
CssClass="total" Height="16px" Width="90px" MaxLength="10"
ReadOnly="True"></asp:TextBox>
</td>
<td class="style59">
Please help me to solve it thanks in advanced