By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,776 Members | 1,269 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,776 IT Pros & Developers. It's quick & easy.

How to Convert Enter Key with Tab Key Functionality

P: 3
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
Share this Question
Share on Google+
3 Replies

dmjpro
100+
P: 2,476
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
100+
P: 2,476
sorryy i did a little mistake

don't use ............. return false
Feb 15 '07 #3

acoder
Expert Mod 15k+
P: 16,027
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.