Function entertotab (event ){
VaR E = event? Event: window. Event
If (E. keycode = 13 ){
E. keycode = 9;
}
}
<Form>
<Input type = "text" id = "input1" onkeydown = "entertotab (event);"/>
<Input type = "text" id = "input2" onkeydown = "entertotab (event);"/>
<Input type = "text" id = "input2" onkeydown = "entertotab (event);"/>
<Input type = "text" id = "input2" onkeydown = "entertotab (event);"/>
<Input type = "Submit">
</Form>
Note: The e. Which attribute of Firefox is read-only and cannot be changed. Therefore, the above aspect can only be used in IE browsers.
Event, you can only use the onkeydown event, instead of the onkeypress event, because for the onkeypress event,
Event. keycode (IE) and E. Which (Firefox) cannot read the Enter key (13), so the onkeydown event must be used.
The following shows the jquery solution, which is compatible with IE and Firefox.
$ (Document). Ready (function (){
// Get only (input: Text) tags with class data-entry
Textboxes = $ ("input: Text ");
// Now we check to see which browser is being used
If ($. browser. Mozilla ){
$ (Textboxes). keypress (checkforenter );
} Else {
$ (Textboxes). keydown (checkforenter );
}
});
Function checkforenter (event ){
If (event. keycode = 13 ){
Currentboxnumber = textboxes. Index (this );
If (textboxes [currentboxnumber + 1]! = NULL ){
Nextbox = textboxes [currentboxnumber + 1]
Nextbox. Focus ();
Nextbox. Select ();
Event. preventdefault ();
Return false;
}
}
}