Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q471 How can I simulate the tab key when the enter key is pressed?

irt.org | Knowledge Base | JavaScript | Form 2 | Q471 [ previous next ]

Q471 How can I simulate the tab key when the enter key is pressed?

If the data has been changed, then when the enter key is pressed the form fields onChange event handler is tripped. You can use this to set the focus on another form field:

<form name="myForm">
<input type="text" name="text1" onChange="this.form.text2.focus()">
<input type="text" name="text2" onChange="this.form.text3.focus()">
<input type="text" name="text3">
</form>

If the value of the form fields haven't changed then you can still capture the enter key using the onBlur event handler:

<form name="myForm">
<input type="text" name="text1" onBlur="this.form.text2.focus()" onChange="this.form.text2.focus()">
<input type="text" name="text2" onBlur="this.form.text3.focus()" onChange="this.form.text3.focus()">
<input type="text" name="text3">
</form>

Feedback on 'Q471 How can I simulate the tab key when the enter key is pressed?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.