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?
精彩评论