---
# System prepended metadata

title: 按鈕submit enter 狀態
tags: [火箭]

---

# 按鈕submit enter 狀態
###### tags: `火箭`

# 不會按下enter就submit

```javascript=
<script type="text/javascript">
document.onkeydown = function() { 
if (window.event) 
if (event.keyCode == 13 && event.srcElement.nodeName != "TEXTAREA" && event.srcElement.type != "submit") 
event.keyCode = 9; 
} 
</script>
```

# 在input 裡面設定name 及onKeyDown 事件(指的是鍵盤按下的時候!)
如果在M1輸入完後按ENTER 就會跳到M2
以此類推M2~>M3， M3~>M4 ， M4~>M4。
```javascript=
<input type=text  name="M1" onKeyDown = "return next(event,'M2');">
<input type=text  name="M2"  onKeyDown = "return next(event,'M3');">
<input type=text  name="M3"  onKeyDown = "return next(event,'M4');">
<input type=text  name="M4"  onKeyDown = "return next(event,this.name);">
```
說明:
keyCode =9 =>tab
keyCode =13 =>enter




https://penguin1989930.pixnet.net/blog/post/334102465