What is JotForm?
JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.

At JotForm, we want to make sure that you’re getting the online form builder help that you need. Our friendly customer support team is available 24/7.

We believe that if one user has a question, there could be more users who may have the same question. This is why many of our support forum threads are public and available to be searched and viewed. If you’d like help immediately, feel free to search for a similar question, or submit your question or concern.


  • Profile Image

    When Radio Buttons have the focus, ENTER submits form

    Asked by simmonscomputer on August 28, 2013 at 06:59 PM

    I have the ENTER key disabled using javascript that I got from this forum.  This works just fine for all fields on my form except radio buttons.  If a user presses enter when any of my radio buttons have the focus, the form is submitted.  If they press enter on any of the other fields, the form is not submitted.   I need ENTER to be disabled when radio buttons have the focus.  What am I doing wrong?  Here is link to my form:

    http://ctextiles.com/onlineapp.htm

     

    If you look at the source, you can see that the javascript I am using to disable the ENTER key is:

    <script language=javascript type=text/javascript>

    <!-- Script courtesy of http://www.web-source.net - Your Guide to Professional Web Site Design and Development 

    function stopRKey(evt) {

       var evt = (evt) ? evt : ((event) ? event : null);

       var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);

       if ((evt.keyCode == 13) && (node.type=="text")) {return false;}

    }

    document.onkeypress = stopRKey; 

    -->

    </script>

     

    What am I missing?

    Page URL:
    http://ctextiles.com/onlineapp.htm

  • Profile Image
    JotForm Support

    Answered by Goldo on August 28, 2013 at 07:59 PM

    You will need to add onKeyPress="return stopRKey(evt) to all input type="checkbox" and to all input type="radio" .

    So from from example below.

    <input type="radio" class="form-radio" id="input_15_0" name="q15_areThere15" value="Yes" />

    it should be like below.. just add

    <input type="radio" class="form-radio" id="input_15_0" name="q15_areThere15" value="Yes" onKeyPress="return stopRKey(evt)"/>


    That should do it.

  • Profile Image
    JotForm Support

    Answered by Welvin on August 28, 2013 at 07:59 PM

    Hi,

    Good day! You will need to add Radio and Checkbox Properties to the Javascript Codes for Stopper. Use the codes from this bin: http://pastebin.com/YLazbvaQ

     

    Thanks

  • Profile Image
    JotForm Support

    Answered by Goldo on August 28, 2013 at 08:03 PM

    Welvin's code should obtain the same result. Use it instead. :)

  • Profile Image

    Answered by simmonscomputer on August 28, 2013 at 08:22 PM

    Thanks, that works great. You guys are awesome!

  • Profile Image

    Answered by happysmart on April 02, 2015 at 03:59 AM

    I have multiple pages form and it used to submit last Thank You page (which is page17) when i used to hit Enter button on the very first page even having required fields.

    So inserted this code and it solved the problem!

     

    <script language=javascript type=text/javascript>

    <!-- Script courtesy of http://www.web-source.net - Your Guide to Professional Web Site Design and Development 

    function stopRKey(evt) {

       var evt = (evt) ? evt : ((event) ? event : null);

       var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);

       if ((evt.keyCode == 13) && (node.type=="text")) {return false;}

    }

    document.onkeypress = stopRKey; 

    -->

    </script>

  • Profile Image

    Answered by KadeJM on April 02, 2015 at 10:23 AM

    @ happysmart 

    I've moved your thread here even though it is a related response about this topic which helped you.