Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Gravity Perks // GP Copy Cat // Copy Credit Card Name to Name Field
<script>
/**
* Gravity Perks // GP Copy Cat // Copy Credit Card Name to Name Field
* http://gravitywiz.com/
*/
gform.addFilter( 'gppc_copied_value', function( value, $targetElem, field ) {
if( field.source.split( '.' ).pop() != 5 ) {
return value;
}
$source = jQuery( '#input_' + field.sourceFormId + '_' + field.source.split( '.' ).join( '_' ) );
if( $source.parents( '.ginput_container_creditcard' ).length <= 0 ) {
return value;
}
// Stripe removes the "name" attribute so that the input's value is not submitted; GPCC does not account for this
// so let's get the value from our source input.
value = $source.val();
var $span = $targetElem.parents( 'span' );
if( $span.hasClass( 'name_first' ) ) {
value = value.split( ' ' ).shift();
} else if( $span.hasClass( 'name_last' ) ) {
values = value.split( ' ' );
values.shift();
value = values.join( ' ' );
}
return value;
} );
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.