Pressing Enter is Submitting the Form

  • patricefn
    Asked on October 25, 2015 at 8:13 PM

    Good Morning,

     

    We have an offer sheet form set up and when pressing enter in a field it automatically submits it. I have had a look in the settings and cannot find a way to disable this. Can you please help. Thankyou Patrice

  • mert JotForm UI Developer
    Replied on October 26, 2015 at 4:37 AM

    Hi there,

    As a quick solution, you can make some of your fields "Required", so the form doesn't accept the "enter" key command.

     

    To do that, select desired field, then click the "Required" button.

    Pressing Enter is Submitting the Form Image 1 Screenshot 20

     

    I hope this one will help.

    Thanks.

  • patrice
    Replied on October 26, 2015 at 11:52 PM

    Hi Mert

     

    Unfortunately we cannot make all fields required as they are not and clients using the form will not have all the details for every field sometimes. is there another way around this? 

     

    Thanks 

    Patrice

  • mert JotForm UI Developer
    Replied on October 27, 2015 at 3:44 AM

    Hi again,

    Patrice, I understand what you are trying to say. If so, we need to try more advanced method to achieve.

     

    To do this,

    1) You need to get your form's HTML source code.

    Pressing Enter is Submitting the Form Image 1 Screenshot 20

     

    2) You need place that source code to your web page.

    3) Then, insert the following javascript code inside the <head>...</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>

     

    I hope this method is what you really need. Please, let us know, if you encounter any error.

    Thanks.

  • patricefn
    Replied on October 27, 2015 at 7:08 PM

    Hi Mert, We were only going to be using the link for the form not importing it into the website. Is there a way to prevent the enter button submitting the form when only using the link or must it be put on our website as that is really not ideal. Would you like our login details? 

  • jonathan
    Replied on October 27, 2015 at 11:45 PM

    I checked your jotform https://form.jotform.com/52880903681966 and I found that none of the form fields were set as *Required .

    This means that the form can be submitted without answering or providing any data at all.

    I suggeste you set at least one field as mandatory or *Required so that the end user will be oblige to provide the necessary data before they can submit the form.

    Pressing Enter is Submitting the Form Image 1 Screenshot 20

    This option will also prevent the form from getting submitted unintended with empty data when using the Enter keyboard. 

    Hope this help. Let us know if you need further assistance on this.

  • patricefn
    Replied on October 28, 2015 at 12:31 AM

    Hi Mert and Jonathan

    I have changed some fields to required but if those fields have been filled in and they press enter accidentally it still submits the form. We cannot make all fields required as they may not have all the information to fill all fields

     

     

    Thankyou

  • mert JotForm UI Developer
    Replied on October 28, 2015 at 2:37 AM

    Hi again,

    Patrice, you can use "Show/Hide a Field" condition to hide submit button. By doing this, submit button will remain hidden until every field is filled.

     

    To add this condition, you need to open "Conditions", then select "Show/Hide a Field". 

    Pressing Enter is Submitting the Form Image 1 Screenshot 30

     

    The settings for that condition will be like the following image. This condition will work like a "Required", but do not let the user pass until every single field is filled. A

    Pressing Enter is Submitting the Form Image 2 Screenshot 41

     

    I think this one will help you. Please, let us know the updates.

    Thanks.

  • patricefn
    Replied on October 28, 2015 at 2:44 AM

    Hi Mert, 

     

    this will not resolve the issue. As i have said multiple times before in this thread - our clients may not fill in every field. They may not have the information to fill in every field. '

    We basically need it disabled for our account for forms to be submitted via the enter button. 

    None of the suggestions match what we are looking for and i feel like we are just going around in circles. 

     

    Thankyou 

    Patrice 

  • mert JotForm UI Developer
    Replied on October 28, 2015 at 4:20 AM

    Hi Patrice,

    I understand what you want and I have an alternative solution for you. Adding a "Captcha" to your form could prevent submitting with "Enter" key.

     

    To add "Captcha" to your form,

    Pressing Enter is Submitting the Form Image 1 Screenshot 30

     

    In addition, you have some other captcha alternatives on "Widgets" tab.

    Pressing Enter is Submitting the Form Image 2 Screenshot 41 

     

    Please, let us know the updates.

    Thanks.

  • patricefn
    Replied on October 28, 2015 at 8:20 PM

    We really would prefer not to put a captcha on the form as this is an official offer sheet to purchase a house and a captcha on it makes it look unprofessional. 

  • jonathan
    Replied on October 28, 2015 at 9:49 PM

    By default the Enter key will submit the form https://form.jotform.com/52880903681966 once the Submit button or a Textbox fields are the focused element on the form.

    This is a built-in process.

    We have been suggesting to you different ways that will stop the form submissio if no data was provided yet. If you do not put *Required to any of the questions/fields on your form, then the form will not be able to capture data/info when it is submitted.

    If you really want to block the Enter key, then you will have to influence the form function using additional script function.  This option was suggested already by our colleague mert

    You will need to use the form's source code though as it will not work if using only the link/URL of the form.

    To do this,

    1) You need to get your form's HTML source code.

    Pressing Enter is Submitting the Form Image 1 Screenshot 20

     

    2) You need place that source code to your web page.

    3) Then, insert the following javascript code inside the <head>...</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>

     

    Let us know if  you need further clarification on this.

     

     

     

  • Helenium
    Replied on April 7, 2016 at 5:12 PM

    RE: <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>

    I put that script on my page (I use Dreamweaver and know how to do that) and it still submits the form when pressing the <enter> key. Even worse, I have a conditional calculation on my form, that says to check one box if you're a NY State resident and the other if you're not. Hitting "return" defaults to NY State, causing sales tax to be added as the form submits.

    I can see from reading the other answers to this question that JotForm doesn't think this is a necessary option, but if that's the best you've got, JotForm won't work for us! We can't have clients receiving receipts saying sales tax has been automatically added when it shouldn't be.

  • Nik_C
    Replied on April 7, 2016 at 5:46 PM

    I'm sorry, we are doing our best to find solution that will work for you. 

    Could you please try to input this script code:

    $("form").bind("keypress", function (e) {

        if (e.keyCode == 13) {

            $("#btnSearch").attr('value');

            //add more buttons here

            return false;

        }

    });

    or you can use also e.preventDefault() instead of return false.

    Please let us know if this works for you.

     

  • Helenium
    Replied on April 7, 2016 at 8:54 PM

    No, same problems -- hitting <enter> submits the form and adds the sales tax when it's not supposed to. I tried it with return false; e.preventDefault() and e.preventDefault();. All the same result.

  • jonathan
    Replied on April 7, 2016 at 10:02 PM

    @Helenium

    I created a dedicated thread to your issue here https://www.jotform.com/answers/813418

    Let us resolve it separately on that thread.

    Thanks.

  • Helenium
    Replied on April 8, 2016 at 1:45 PM
    Okay, thanks!
    ...