Disable Submission when Pressing Enter
Instructions
- Install our free Custom Javascript for Gravity Forms plugin. Download the plugin here: https://gravitywiz.com/gravity-forms-code-chest/
- Copy and paste the snippet into the editor of the Custom Javascript for Gravity Forms plugin.
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;
}
} );
Hello, is there any way to achive this while using the Gravity Forms Conversational Forms add on? The current snippet doesn’t seem to work with Conversational Forms. Thanks!
Hey Laurence,
You’re right! I’ve tested this locally and it indeed looks like it doesn’t work with the Gravity Forms Conversational Forms Add-on. I’ve submitted a feature request to look at possibly updating the snippet to support this.
Hey Laurence,
Can you please try this updated version of the snippet:
https://github.com/gravitywiz/snippet-library/blob/saif/fix/83124-fix-disable-submit-gf-conversational/gravity-forms/gw-disable-submission-on-enter.js
Let us know how it goes for you!