Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

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

You are here: irt.org | FAQ | JavaScript | Form | 2 | Q471 [ previous next ]

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?'

©2018 Martin Webb