Submit a form with the <ENTER>; Key

davecoventry's picture

He has: 112 posts

Joined: Jun 2009

I have a form that I want to submit using the <RETURN> key.

$("#dimform").submit(function(){
})

never gets called and

$('#sendfield').keydown(function(e){
if (e.which == 13) {
}
})

gets fired too early because the user hits return when the browser autocompletes.

Surely this must be a common problem? Why can't I find anything on google?

davecoventry's picture

He has: 112 posts

Joined: Jun 2009

Sorry, I had my form as below:

<form name="dimform">

I've changed this to:

<form name="dimformName" id="dimform">

Which solves the problem.
(silly bugger!)

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.