How to stop form submitting when 'enter' is pressed?

  • Profile Image
    Asked on March 31, 2014 at 09:14 AM

    A user (on Sarari) was filling in the form and everytime he pressed enter, the form submitted.  How do I stop this happening?


  • Profile Image
    Answered on March 31, 2014 at 10:59 AM

    I will look further for a code solution on this and will get back to you.

    Thank you

  • Profile Image
    Answered on April 06, 2014 at 04:04 PM

    It is necessary that you download and edit the form's source code: 

    Now it is necessary that you paste only the green parts into your form's source code. The script part is inserted inside the <head> tag. The "onkeydown" needs to be added to all the fields where we wish to disable enter key:




    <SCRIPT LANGUAGE="javascript"> function testForEnter() { if (event.keyCode == 13) { event.cancelBubble = true; event.returnValue = false; } } </SCRIPT> 



    <FORM id="FORM2" name="FORM2" method="GET" action="testSubmit.htm" style="background-color:lightblue"> <H3>Form2: Stops form submission when user presses ENTER key.</H3> <INPUT id="text2" name="text2" onkeydown="testForEnter();"> <INPUT type="submit" value="Submit">





    You can test this form. Only the name field has this code associated, because it is important to keep the enter function on the comment box:

    Let us know if we can be of assistance.

    Thank you

  • Profile Image
    Answered on May 17, 2016 at 04:56 PM

    For some reason your reply seems to have come empty, please let us know if you need more help we will be glad to assist you.

  • Profile Image
    Answered on May 18, 2016 at 03:44 AM
    Hi, thanks for the message, the matter is solved so no further action
    required. Thank you.
    Kate Siraj
    Ayurvedic Practitioner
    BSc Ayurveda (Manipal), MChem (Oxon), MAPA
    020 3166 5086 / 07980 285 268
    22 Hogarth Way, Hampton, TW12 2EL
  • Profile Image
    Answered on June 06, 2016 at 07:40 PM

    This is nuts.  If I could figure out how to do this, I probably would not have needed JOTFORM in the first place.  Please, Jotform, give us another solution.

  • Profile Image
    Answered on June 06, 2016 at 08:47 PM

    @PCIrish, I see you have opened a thread for your concern:, you will be assisted there, thanks.