Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions gravity-forms/gw-disable-submission-on-enter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Loading