Reputation: 3415
I have a form whose submit "button" is actually a link. Is there a way to submit this form automatically on enter, other than attaching an event handler to check for Enter keypresses? It just seems a little wasteful to me.
Upvotes: 1
Views: 313
Reputation: 11704
I have tested in Chrome and Firefox, it appears that pressing enter in a form field will submit it, whether or not a submit button is present.
If you've found a browser where that isn't the case, you may want to try a submit button in a hidden div, or CSS positioned off-screen.
Or stick to conventions and use a submit button :P
Upvotes: 2
Reputation: 9351
Throw some jquery on there and submit the form with it:
$("form#formID").submit();
Upvotes: 0