You are here: irt.org | FAQ | JavaScript | Form | 2 | Q774 [ 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>
Alternatively, you can use the onBlur event handler to trap something similar:
<FORM NAME="myForm"> <INPUT TYPE="TEXT" NAME="text1" onBlur"this.form.text2.focus()"> <INPUT TYPE="TEXT" NAME="text2" onBlur="this.form.text3.focus()"> <INPUT TYPE="TEXT" NAME="text3"> </FORM>
However, not all of the older browsers/operating systems support the onBlur event handler.