2

Hi i'm currentyl having an issue with a form on a website, im using a link instead of a button or an input to submit a form, but i cannot seem to make it submit when the user press the enter key, the Form values are being validated using javascript with the following format onsubmit="return function();"

Anybody knows how to make it submit on enter keypress ?

Thanks

DJ22T
  • 1,628
  • 3
  • 34
  • 66
  • 4
    why don't you style the button to look like a link? :) – epascarello Mar 20 '13 at 15:15
  • Submitting a form by pressing enter : http://stackoverflow.com/questions/477691/submitting-a-form-by-pressing-enter-without-a-submit-button – loxxy Mar 20 '13 at 15:17
  • Thanks @epascarello it worked flawlessly haven't tought about it :) This is what i wanted to achieve http://jsfiddle.net/5vHGc/52/ – DJ22T Mar 22 '13 at 13:13

1 Answers1

3

Try capturing the event.keyCode property when hitting a key on the particular link.

   $('#example').keyup(function(event) {
      if(event.keyCode === 13) {
        //do what you want
        **EDIT:** $('$FormName').submit();
      }
   });
Vincent Durmont
  • 813
  • 8
  • 16
theshadowmonkey
  • 689
  • 8
  • 26