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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Keypress in JavaScript

Status
Not open for further replies.

lunargirrl

Programmer
Jan 26, 2004
77
BR
I'd like to know how can I make keypress when the enter key is pressed, to jump to the next field on a form.


Thank you.
venusgirrl
 
<input type="text" ..... onkeydown="event.keyCode==13:document.FormName.NextField.focus():''">

Known is handfull, Unknown is worldfull
 
vbkris, thank you for the quick answer.
but it gives me the message (i am translating from my language):
"error: waiting for ;"

thanks,

venusgirrl
 
Try this:

Code:
<input type="text" onkeydown="(event.keyCode==13):this.form.NextField.focus();:;">

It assumes that you would replace "NextField" with the name of the field you want focusses when enter is pressed.

Hope this helps,
Dan
 
thanks dan!

but I still get the same error:
"waiting for ;"


how is my line:

<asp:textbox id="txt_Empresa" tabIndex="1" runat="server" MaxLength="30" onkeydown="(event.keyCode==13):this.form.cboParceiro.focus();:;">
</asp:textbox>


i am using asp.net

thanks ;)
venusgirrl
 

Sorry - that ASP stuff isn't my thing... And given that you never mentioned anything about ASP, don't you think it would be hard for us to give you a working solution? Try the ASP or ASP.Net forums instead.

*grumble*

Dan
 
yup, thats .net, i dont think u should insert javascript like that in .net...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top