Hi,
I have a currency conversion application that needs some Javascript to do some validation on the 'onkeypress' event on a textbox (txtAmount) so that:=
if the validation passes (ie a number is entered) then the application populates a textbox by multiplying the contents of the entire textbox by an exchange rate (ie txtAmount contains 1234, each number entered is validated correctly then the entire contents is * by an exchange rate)
or
the validation fails and a message is sent to the user to warn him that a non-numebrik keystroke has been entered and also, deletes the erroneous keystroke that has been entered (ie 1234X will produce an error and the 'X' will be deleted from txtAmount)
I do not know Java, so any help would be much appreciated, there is an article on the site that appears to do the trick, but I cannot down load it.
Thanks
Paul
Validating and processing asp.net textbox
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Santhosh NRank #4,788 · 325 reputationPosted Dec 30, 2009, 7:20 AM EST
you could do that using onkeypress event of textbox in javascript as.. function numbersonly(e) { var unicode=e.charCode? e.charCode : e.keyCode if (unicode!=8) //if the key isn't the backspace key allow that { if (unicode57) //if it is not a number, then only allow return false; //disable key press, or you can alert a user like alert('invalid number'); } }