Disable Return/Enter button as way to submit form?

Home Forums Quform WordPress Disable Return/Enter button as way to submit form?

This topic is: resolved
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #8512
    brettlondon
    Participant

    Is there a way to disable submitting the form by simply pressing the Return/Enter button on the keyboard?

    I ask because if in the middle of filling out the form if someone hits the Enter button by mistake, the form is either sent half filled out and then cleared of all data, or errors pop up and it gets messy.

    So is there a way to make the form only submittable by clicking the Send button?

    Thanks!

    #8538
    dreoin
    Participant

    While I don’t have/know the solution, I have a work around.

    We have an issue with people using the “enter” key when typing their name in a form on a software keyboard on an ipad. We solved the issue by making another field required so that they would get an error rather than accidentally submitting the form. So field A would ask that the person to type in a text field and field B would be a required question which would prevent the “enter” key being used in field A from submitting the form.

    Eoin

    #8543
    josef777
    Participant

    Try the following code :


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

    #8547
    dreoin
    Participant

    Josef,
    Would you insert the custom code in the form somewhere or would this be a plug-in wide setting?
    Eoin

    #8548
    josef777
    Participant

    Eoin
    go to edit your form and Add html field at the end of your form and put the code in it

    You can test it Here

    #8561
    brettlondon
    Participant

    That works perfectly!

    Thanks so much for all the assistance on this!

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy