Omu
Omu

Reputation: 71198

form is not submitted on enter key when there is no submit button inside

is there some fix for this

<form>
<input type="text" ...

</form>

hitting the enter key inside the textfield when there is no submit button inside doesn't submit the form, is there some fix for this ?

Upvotes: 3

Views: 685

Answers (2)

David Espart
David Espart

Reputation: 11780

You could use the keyup event of jquery and if the key pressed is 13 (enter key code) then submit the form:

$('#input-id').keyup(function(e) {
    if (e.keyCode == 13) {
        $('#form-id').submit();
    }
});

Upvotes: 2

Muneer
Muneer

Reputation: 7564

My suggestion is.. Create a submit button. If you do not want to show the submit button, then hide the button using CSS.

Upvotes: 6

Related Questions