已填写条形验证卡元素

问题描述 投票:0回答:1

[使用保存的卡片或元素时,我需要在点击提交时验证一个或另一个。

我可以轻松看到自己保存的插卡收音机,但Stripe元素位于iframe中。

填写卡后是否会触发事件?或以某种方式检查是否可以提交。我确定我缺少明显的东西。

类似这种情况

form.addEventListener('submit', function(event) {
                event.preventDefault();
                $('button.buy').prop('disabled', true);
                if ($('.saved_cards input[type="radio"]:checked')) {
                    self.save_card = false;
                    self.payment_method = $('.saved_cards input[type="radio"]:checked').val();
                    self.make_payment().then(self.handleMakePaymentResponse);
                } else {
// There should be a way to validate card is filled out
// Stripe validates as you type but no way to know it is simply done.
// we need to know this is filled out.
                    stripe.createPaymentMethod({
.........
validation stripe-payments
1个回答
0
投票

您将在Element上侦听change事件,然后在事件处理程序对象上检查complete字段:https://stripe.com/docs/js/element/events/on_change?type=cardElement

© www.soinside.com 2019 - 2024. All rights reserved.