How to submit a form when the return key is pressed?

前端 未结 15 1044
既然无缘
既然无缘 2020-11-28 04:25

Can someone please tell me how to submit an HTML form when the return key is pressed and if there are no buttons in the form? The submit button is not there

15条回答
  •  旧巷少年郎
    2020-11-28 04:46

    I believe this is what you want.

    //
    

    Every time a key is pressed, function enter() will be called. If the key pressed matches the enter key (13), then sendform() will be called and the first encountered form will be sent. This is only for Firefox and other standards compliant browsers.

    If you find this code useful, please be sure to vote me up!

提交回复
热议问题