OnKeyPress event doesn't work in netscape?

J

jrice

This code works perfectly in IE, but does not work in Netscape 7....It
is designed to force the user to only enter numbers into a textbox. I
also want to allow them to tab over the box as well as handle an enter
key press while they are in the textbox. Here is the code.....

OnKeyPress="javascript:if(navigator.userAgent.indexOf("MSIE")!=-1)
{var keyCode = event.keyCode;}else {var keyCode = event.which;}if
(keyCode > 47 &amp;&amp; keyCode < 58 || keyCode==8 ||
keyCode==9){return true;} else{return false};" /></td>
</tr>

anyone give me any insight into why this will not work in Netscape? if
you can please e-mail me directly.....

Thanks in advance
 
R

Roedy Green

OnKeyPress="javascript:if(navigator.userAgent.indexOf(&quot;MSIE&quot;)!=-1)
{var keyCode = event.keyCode;}else {var keyCode = event.which;}if
(keyCode > 47 &amp;&amp; keyCode < 58 || keyCode==8 ||
keyCode==9){return true;} else{return false};" /></td>
</tr>

anyone give me any insight into why this will not work in Netscape? if
you can please e-mail me directly.....

see http://mindprod.com/jglossl/javascript.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top