开发者

HTML form - normal button prevents submitting the form on Enter

I have a form with some

<button>

elements and a normal

<input type="submit">

button to submit the form.

However, when I press Enter when I'm in a textfield, the form does not get submitted but much rather the first Element is "pressed".

开发者_如何学编程

How can I change this behavior?


I would recommend changing the <button> tag and turning it into an <input type="button" /> tag. This should force the form to submit the way you want.


You can use javascript to capture that the Enter key was pressed and submit the form.

See this example.

For a complete answer, could you please post your HTML?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜