Skip to content

Instantly share code, notes, and snippets.

Last active May 22, 2019 08:14
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Disables form submission when pressing Enter, unless user has tabbed to submit button or page advance button.
function twxyz_prevent_gform_submission( $form ) { ?>
<script type="text/javascript">
jQuery(document).bind('gform_post_render', function(){
jQuery(document).on( 'keypress', '.gform_wrapper', function (e) {
var code = e.keyCode || e.which;
if ( code == 13 && ! jQuery( ).is( 'textarea,input[type="submit"],input[type="button"]' ) ) {
return false;
<?php return $form;
add_action( 'gform_pre_render', 'twxyz_prevent_gform_submission' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment