A lot of wordy customers like to put forward these needs! In fact, it is not difficult to achieve! The code is as follows:
I looked at MS's asp.net lectures some time ago, in which I talked about how to get the "enter" to move the focus of the text box down. One of the three methods, the best one is this:
Using client script to add the document's onkeydown event to the page, let the page perform the TAB function after receiving the carriage return event, that is, just change the event's KeyCode from 13 to 9
VBScript code:
<script language= "VBScript" >
Sub Document_onkeydown
If Event.keycode=13 Then
Event.keycode=9
End If
End Sub
</script>
The JavaScript code is as follows:
<script language= "javascript" for= "document" event= "onkeydown" >
<!--
if (event.keycode==13)
event.keycode=9;
-->
</script>
This way of handling, can realize the focus of moving down, but for the button also plays the same role, the general customer after entering the data, jump to the button, it is best to directly press "enter" to submit data. Therefore, the above method should be modified to the "submit" The button does not shift focus. Direct activation commits.
So I made a modification to the above code, that is, to determine the "source" of the event, is the Submit button, the code is as follows:
<script language= "javascript" for= "document" event= "onkeydown" >
<!--
if (event.keycode==13 && event.srcelement.type!= ' button ' && event.srcelement.type!= ' Submit ' & & event.srcelement.type!= ' reset ' && event.srcelement.type!= ' textarea ' && event.srcelement.type! ='')
event.keycode=9;
-->
</script>
To determine if it is a button, because there will be a type= "button" on the HTML
To decide whether to submit, because the HTML will have type= "submit"
To determine if reset is because the "reset" on HTML should be executed
To determine whether it is empty, because the "link" on HTML should also be executed, this situation occurs not much, you can use the "Tabindex=-1" way to cancel the link to get focus.