Hi,
I have a page with multiple forms and was wondering if there was any examples showing how to submit the current form you filled in when hitting enter?
Thanks
Hi,
I have a page with multiple forms and was wondering if there was any examples showing how to submit the current form you filled in when hitting enter?
Thanks
Submit the closest form
$("element").closest("form").submit();
You have to add an event keydown
and submit the closest form:
$("input[type=text]") // retrieve all inputs
.keydown(function(e) { // bind keydown on all inputs
if (e.keyCode == 13) // enter was pressed
$(this).closest("form").submit(); // submit the current form
});
The default behavior of browsers, when hitting enter while inside a form element, is to submit the form that the element belongs to ..
So you have nothing to worry about, unless i am misunderstanding the question ..