Stripe recommends using the change event for client side validation of the card element:
cardElement.on('change', function(event) {
if (event.complete) {
// enable payment button
} else if (event.error) {
// show validation to customer
}
});
However this approach makes it impossible to determine a card element is invalid if the user never edits / changes it. I can always try to submit the payment with confirmCardPayment but that is inefficient—this validation should be possible client-side.
I can work around this by having the payment form default to an error state that is then resolved (or not) the first time the user changes the card. However this is not convenient as it would require me to internationalize the "Your card number is incomplete" error message in my application code versus relying on Stripe to this.
Ideally I would be able to either synchronously check the card element for an error or at least synchronously trigger the change event but neither of these seem possible.