I have an HTML form with a single submit input, but also with various button elements. When the user presses the 'enter' key, I expect it to actually submit the form, but instead (within at least 15) I find that it launches the first button (since this happens earlier in the HTML than the submit input, I think).
I know that in general, you cannot force browsers to support a specific submit input, but I really thought that they would approve submit inputs via button elements. Is there a little tweak I can make for HTML to make this work, or will I have to take some kind of Javascript approach?
Here is a crude HTML layout:
<form action="form.php" method="POST"> <input type="text" name="field1"/> <button onclick="return myFunc1()">Button 1</button> <input type="submit" name="go" value="Submit"/> </form>
html forms
andygeers Nov 28 '11 at 10:27 2011-11-28 10:27
source share