Skip to content

Commit 7e5500f

Browse files
committed
gw-disable-submission-on-enter.js: Fixed an issue with disable enter snippet not working with Conversational Forms.
1 parent cf5dfa5 commit 7e5500f

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

gravity-forms/gw-disable-submission-on-enter.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
* Download the plugin here: https://gravitywiz.com/gravity-forms-code-chest/
88
* 2. Copy and paste the snippet into the editor of the Custom Javascript for Gravity Forms plugin.
99
*/
10-
jQuery(document).on( 'keypress', '.gform_wrapper', function (e) {
11-
var code = e.keyCode || e.which;
12-
if ( code == 13 && ! jQuery( e.target ).is( 'textarea,input[type="submit"],input[type="button"]' ) ) {
13-
e.preventDefault();
14-
return false;
15-
}
16-
} );
10+
document.addEventListener( 'keydown', function(e) {
11+
var isGravityForm = e.target.closest( '.gform_wrapper' ) !== null;
12+
var code = e.keyCode || e.which;
13+
if ( code == 13 && ! jQuery( e.target ).is( 'textarea,input[type="submit"],input[type="button"]' ) && isGravityForm ) {
14+
e.stopImmediatePropagation();
15+
e.preventDefault();
16+
}
17+
}, true );

0 commit comments

Comments
 (0)