471,120 Members | 1,299 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,120 software developers and data experts.

How to Convert Enter Key with Tab Key Functionality

hi friends,
if we press Enter Key , the Focus should change to next TextField.
Actually we can do this using JavaScript. i got that Code in this Forum only.
its working fine,means when i press EnterKey , focus is going to Next Control.
But its now Working when the Focus is in "InputFile Control" which we will use for some File Uploadings.

the code is ::
<script language="javascript">
function kH(e) {

var pK = document.all? window.event.keyCode:e.which;
return pK != 13;
}

document.onkeypress = kH;
if (document.layers) document.captureEvents(Event.KEYPRESS);
</script>

<body onkeydown="if(event.keyCode==13){event.keyCode=9;r eturn event.keyCode}" >


This is NOT working when the Focus is in InputFile Html Control .that is
<input type="file" id="id1" >
How to change to correct this
Feb 15 '07 #1
3 8183
dmjpro
2,476 2GB
ur code should be like this ....

<script language = javascript>
function startPage()
{
try
{
document.onkeypress = kH;
if (document.layers) document.captureEvents(Event.KEYPRESS);
}catch(err)
{
alert(err.description);
}
function KH(e)
{
try
{
var pK = document.all? window.event.keyCode:e.which;
return pK != 13;
}catch(err)
{
alert(err.description);
}
}
}
</script>

<body onload = startPage() onkeydown="if(event.keyCode==13){event.keyCode=9;r eturn false;}" onkeypress="if(event.keyCode==13){event.keyCode=9; return false;}" onkeyup="if(event.keyCode==13){event.keyCode=9;ret urn false;}">

if any error then it will flash in a alert box ....
point out the error

and then tell me what the problem u exactly faced

welcome in advance
i am online
Feb 15 '07 #2
dmjpro
2,476 2GB
sorryy i did a little mistake

don't use ............. return false
Feb 15 '07 #3
acoder
16,027 Expert Mod 8TB
I may be wrong, but it may be because you are not allowed to change the value of the file input field. Although with the tab key you are removing focus, yet it is sending a key to the input field. In that case, I suggest you use the blur() method or give focus to the next element instead.
Feb 16 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Keith Smith | last post: by
1 post views Thread by Dave McCloskey | last post: by
4 posts views Thread by kvicky | last post: by
8 posts views Thread by Dan Holmes | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.