diff --git a/paypal/js/frontend.js b/paypal/js/frontend.js index 13371c0a8a..e9bd5bcd33 100644 --- a/paypal/js/frontend.js +++ b/paypal/js/frontend.js @@ -718,7 +718,12 @@ onError, style: frmPayPalVars.style, inputEvents: { - onChange: onCardFieldsChange + onChange: onCardFieldsChange, + onFocus() { + // onBlur only triggers if onFocus is defined. + // But we don't need to do anything on focus. + }, + onBlur: onCardFieldsBlur } }; @@ -749,6 +754,19 @@ } } + /** + * Handle card field blur events. + * This detects autofilled fields that may not trigger onChange. + * + * @param {Object} data The onBlur event data. + */ + function onCardFieldsBlur( data ) { + if ( selectedMethod === 'card' && data.isFormValid ) { + cardFieldsValid = true; + enableSubmit(); + } + } + /** * Render the card number / expiry / CVV fields into the method container. */