Click here to Skip to main content
15,915,319 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
<!DOCTYPE html>
<html>
<HEAD>
<SCRIPT language=Javascript>

function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;

return true;
}

</SCRIPT>
</HEAD>
<BODY>
<INPUT id="txtChar" onkeypress="return isNumberKey(event)" type="text" name="txtChar">
</BODY></html>
Posted
Updated 9-Jul-15 3:49am
v8
Comments
Suvendu Shekhar Giri 9-Jul-15 7:25am    
Is this really Java code? or Javascript?
You have tagged Java.
Member 11825176 9-Jul-15 7:54am    
javascript code
ZurdoDev 9-Jul-15 8:12am    
What doesn't work specifically?
Sreekanth Mothukuru 9-Jul-15 8:17am    
how and where are calling this method ?

1 solution

I googled "onkeypress ie8" and it took less than a minute to find this

http://stackoverflow.com/questions/1750223/javascript-keycode-values-are-undefined-in-internet-explorer-8[^]

Please do your own basic research before asking a question.
 
Share this answer
 
Comments
Member 11825176 10-Jul-15 5:48am    
iam aslo go through all links like you provided but not working

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900