j.s validation for textbox to not to increase the amount

Posted by Kalari under ASP.NET on 8/22/2013 | Points: 10 | Views : 1276 | Status : [Member] | Replies : 0
I gave validation for the text box to not to increase the textbox previous value,and can reduce the previous value.
suppose the textbox previous value is 500 again if i entered 6 in the text box then validation occurs.
that means it is not waiting untill the complete value which i have to entered.
i gave onkeypress and key onkeyup.
here it is checking with the 1st digit itself.
suppose if i want to decrease the value to 65,78,89,...like that means two digit value ,so it has wait untill the completion of the entered value then it has to check it and then validation occurs if it is more than the previous value....
please suggest me..
i gave like this
<asp:TextBox ID="txtdebit" runat="server" CssClass="estbox" ToolTip="Transfered Amount"
Width="182px" onkeypress="compare1()" onkeyup="compare1()"></asp:TextBox>

Calling the function:

<script type="text/javascript" language="javascript" >

function compare1() {
var amount = document.getElementById("<%=txtdebit.ClientID %>").value;
var debit = document.getElementById("<%=hfdebit.ClientID %>").value;

if (amount > debit) {
alert("You are not allowed to increase the amount");
document.getElementById("<%=txtdebit.ClientID %>").value = "";
return false;



(No response found.)

Login to post response