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

前端 未结 15 1029
既然无缘
既然无缘 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:53

    I use this method:

    Basically, I just add an invisible input of type image (where "spacer.gif" is a 1x1 transparent gif).

    In this way, I can submit this form either with the 'send' button or simply by pressing enter on the keyboard.

    This is the trick!

提交回复
热议问题