Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
36
rated 0 times [  43] [ 7]  / answers: 1 / hits: 21564  / 12 Years ago, mon, july 23, 2012, 12:00:00

I am trying to execute some code of js when user press key enter or tab. When I alert keycode then showing correct, but when press key enter or tab then not showing any response.
I tried following code.



<input id=to onkeypress=checkemail(event);>

function checkemail(evt)
{
var keycode = evt.keyCode? evt.keyCode : evt.charCode;
//alert(keycode);
if(keycode=='13'|| keycode=='9')
{
//MyCode
}

}


This code is work properly in FireFox, but not showing any result in Google Chrome.
Please tell me any solution if have.
Thanks in advance.


More From » javascript

 Answers
15
<html>

<body>

<input type = text id = to onkeydown=check(event)>

<script type = text/javascript>

function check(evt)
{
var keycode = evt.keyCode;
alert(keycode);
}

</script>

</body>

</html>


it works in chrome :)


[#84083] Saturday, July 21, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mckinleykeyshawnb

Total Points: 281
Total Questions: 99
Total Answers: 111

Location: Saudi Arabia
Member since Sat, Aug 20, 2022
2 Years ago
;