From 7e5500fc844f64a44b788532078c55175160d47f Mon Sep 17 00:00:00 2001 From: Saif Sultan Date: Fri, 9 May 2025 16:43:31 +0530 Subject: [PATCH] `gw-disable-submission-on-enter.js`: Fixed an issue with disable enter snippet not working with Conversational Forms. --- gravity-forms/gw-disable-submission-on-enter.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/gravity-forms/gw-disable-submission-on-enter.js b/gravity-forms/gw-disable-submission-on-enter.js index a6d9aa269..6b8eae42a 100644 --- a/gravity-forms/gw-disable-submission-on-enter.js +++ b/gravity-forms/gw-disable-submission-on-enter.js @@ -7,10 +7,11 @@ * 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; - } -} ); +document.addEventListener( 'keydown', function(e) { + var isGravityForm = e.target.closest( '.gform_wrapper' ) !== null; + var code = e.keyCode || e.which; + if ( code == 13 && ! jQuery( e.target ).is( 'textarea,input[type="submit"],input[type="button"]' ) && isGravityForm ) { + e.stopImmediatePropagation(); + e.preventDefault(); + } +}, true );