Why does hitting "Enter" in a box submit the form?

  • Profile Image
    dcpsforms
    Asked on October 13, 2016 at 01:30 PM

    How can I fix it so that if someone hits "Enter", it doesn't automatically submit the form?

  • Profile Image
    liyam
    Answered on October 13, 2016 at 03:43 PM

    Hello,

    Unfortunately there is no option to disable the enter button to submit the form. But a workaround can be done. You can get the full source code of your form, place the form's source to your web page and modify the code to disable the enter button on submission of the form.

    Once you have the source of your form in a page, you can insert this code in between the <head> and </head> tags:

    <script type="text/javascript">

    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>

    Thanks.