Last active
August 29, 2015 13:58
-
-
Save hirejordansmith/9958888 to your computer and use it in GitHub Desktop.
Move focus to next gravity form field after input mask completed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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