【发布时间】:2013-12-21 15:49:49
【问题描述】:
点击我网站上的“投稿”按钮后,会出现一个覆盖表单;但是,如果有人在提供信息之前立即单击“发送承诺”,则该按钮将被禁用(与 Stripe 按钮一样)以供进一步使用。因此,他们无法添加信用卡或提交表单;在他们刷新页面之前,它会被永久禁用。
如何更改它以使“发送承诺”按钮在第一次点击后仍处于活动状态?如果需要更多信息,请告诉我。
现场演示可以在这里找到:http://www.cantedpictures.com/9test/
否则:这里是js:
$(function(){
$("#donateModal").on('show', function() {
// Fix StripeButton sizing bug on Firefox and IE
$(".stripe-button-inner, .stripe-button-inner iframe").width(132).height(36);
// ensure button scrolls with the rest of the page
$(".stripe-button-inner iframe").css('position', 'relative');
});
// Stripe Button Triggers formDomElement.submit().
// We intercept it and notify user we have received the token
var paymentForm = $('#payment-form')[0];
paymentForm.original_submit = paymentForm.submit;
paymentForm.submit = function() {
$("#stripe-button-holder .stripe-button-inner").html(
'<span class="label label-success">
<i class="icon-ok"></i> Card Added</span>');
return false;
};
$('#payment-form').validate({
rules: {
'first-name': {
minlength: 1,
required: true
},
'last-name': {
minlength: 1,
required: true
},
email: {
required: true,
email: true
},
amount: {
required: true,
min: 10,
},
'tos-agreed': {
required: true
}
},
messages: {
'tos-agreed': 'You need to agree to the Terms of Service',
'first-name': 'Please give us your first name',
'last-name' : 'Please give us your last name',
'email' : 'Please give us your email so that we can contact you',
'amount' : 'Please pledge at least $10.'
},
errorPlacement: function (error, input) {
$(input).closest('.controls').append(error);
},
highlight: function(el) {
$(el).closest('.control-group').addClass('error');
},
unhighlight: function(el) {
$(el).closest('.control-group').removeClass('error');
},
submitHandler: function(form) {
// ensure CC info has been entered
if (! $('[name=stripeToken]').val()) {
$("#stripe-button-holder").closest('.control-group').addClass('error');
$("#stripe-button-holder").append('<label class="error">
Please Add Payment Information</span>')
window.location.reload();
} else {
form.original_submit();
}
}
});
});//]]>
【问题讨论】:
-
我认为它没有为我禁用(我使用 chrome btw)
-
我应该澄清一下:“贡献”按钮有效,但如果您立即单击它,“发送承诺”按钮将不起作用。单击“贡献”后,如果您立即单击“发送承诺”,则该按钮将永久禁用。
标签: javascript jquery stripe-payments