Disable Submission when Pressing Enter

Instructions

  1. Install our free Custom Javascript for Gravity Forms plugin. Download the plugin here: https://gravitywiz.com/gravity-forms-code-chest/
  2. Copy and paste the snippet into the editor of the Custom Javascript for Gravity Forms plugin.
Read the Walkthrough

Code

Filename: gw-disable-submission-on-enter.js

/**
 * Gravity Wiz // Gravity Forms // Disable Submission when Pressing Enter
 * https://gravitywiz.com/disable-submission-when-pressing-enter-for-gravity-forms/
 *
 * Instructions:
 * 1. Install our free Custom Javascript for Gravity Forms plugin.
 * Download the plugin here: https://gravitywiz.com/gravity-forms-code-chest/
 * 2. Copy and paste the snippet into the editor of the Custom Javascript for Gravity Forms plugin.
 */
jQuery(document).on( 'keypress', '.gform_wrapper', function (e) {
    var code = e.keyCode || e.which;
    if ( code == 13 && ! jQuery( e.target ).is( 'textarea,input[type="submit"],input[type="button"]' ) ) {
        e.preventDefault();
        return false;
    }
} );

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.