vladimirProp
vladimirProp

Reputation: 251

Stripe elements on Change event issue

Hi i regenerate token with every credit card change for cc input field, tried event on change and addEventListener('change')

 card.addEventListener('change', function(event) {
         //billingDataChange();
   })

and

 card.on('change', function(event) {
     //billingDataChange();
   });

Noticed that this event is fired only when you start to type first and last letter, so if you change number in the middle, or when you paste code, token won't be regenerated. Any idea how to solve this issue, maybe with different event or something else

Upvotes: 4

Views: 3175

Answers (1)

Phillip
Phillip

Reputation: 660

With Stripe v3 (at least), if you use the code

var card = elements.create('card')
card.on('change', function(event) {
    //billingDataChange();
});

It should fire correctly. If you manually query the card via a selector, the on change event won't work since stripe adds sub-elements and you won't be referencing the actual element that gets changed.

Upvotes: 3

Related Questions