Substraction between two value with jquery keypress event.
Hi ! i want to substract textbox2 value from textbox1 and display result in textbox3 in asp.net with jquery.i write the following code on textbox2 keypress
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#TextBox2").keydown(function () {
var a = $("#TextBox1").val();
var b = $("#TextBox2").val();
var c = a - b;
$("#TextBox3").val(c);
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Panel ID="Panel1" class="Panel" runat="server">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</asp:Panel>
</div>
</form>
this working but not properly. its result such as
40 - 10 = 39(e.i when i press 3 it does not fire,when press zero then substract 40 - 1 not 40 - 10)
400 - 100 = 390
400 - 10 = 300
please give me a solution.thanks all.