Skip to content

Instantly share code, notes, and snippets.

@hirejordansmith
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hirejordansmith/9958888 to your computer and use it in GitHub Desktop.
Save hirejordansmith/9958888 to your computer and use it in GitHub Desktop.
Move focus to next gravity form field after input mask completed
<?php
/**
* Move focus to next field after input mask completed
*/
// update the "86" to the ID of your form
add_filter('gform_input_mask_script', 'gwiz_input_mask_focus_next', 10, 4);
function gwiz_input_mask_focus_next($script, $form_id, $field_id, $mask) {
$script = "jQuery('#input_{$form_id}_{$field_id}').mask('{$mask}', " .
"{ completed: function() { jQuery(this).parents('li.gfield').next('li.gfield').find('input').focus(); }}" .
").bind('keypress', function(e){if(e.which == 13){jQuery(this).blur();} } );";
return $script;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment