Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing ENTER to TAB on Web Form

Status
Not open for further replies.

MtProgrammer

Programmer
Dec 14, 2004
7
US
I've found how to disable the enter key on a web page, but was wondering if it is possible to alter the input to act as though the TAB key was pressed? I'm using ASP.Net.


 
Do you mean you want to insert a tab character or you want to tab to the next field? If you post the code that you are using to trap the enter key, we can probably alter it to do what you want.

Adam

for(ring=0;ring<rosie;ring++){pocket[ring]='posie';ashes*=2;fall--}
 
The following code is in the HEAD portion of the form. Sorry I wasn't clear about the response, yes I would like to tab to the next field. Thank you in advance for your assistance since much of this is new to me.


<script>
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>
 
Have a look at this recent post: thread216-1044921

Hope this helps,
Dan

[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
Try this:
Code:
<script>
function checkKey(event,nextField){
  var pK = document.all? event.keyCode:event.which;
  if(pK==13 && nextField) document.f.elements[nextField].focus();
  return pK!=13;
}
</script>

<form name="f">
<input type="text" name="t1" onkeypress="return checkKey(event,'t2')">
<input type="text" name="t2" onkeypress="return checkKey(event,'t3')">
<input type="text" name="t3" onkeypress="return checkKey(event,null)">
</form>

Adam

for(ring=0;ring<rosie;ring++){pocket[ring]='posie';ashes*=2;fall--}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top