基金会6遵守表格确认

时间:2017-05-17 21:03:49

标签: javascript validation zurb-foundation abide

是否有办法为Abide表单验证获取truefalse的返回值。我知道你可以在表单提交时调用事件监听器,但是我有一个PayPal结账按钮我不想运行,除非表单有效并且无法控制对它的点击操作,因为它在iFrame中

paypal.Button.render({
    env: 'sandbox',
    client: {
        sandbox: 'xxx'
    },
    payment: function() {
        var env      = this.props.env,
            client   = this.props.client,
            total    = $('#amount-cents').val() / 100,
            $validateError = $('.validate-error'),
            valid = $('#payment-form').foundation('validateForm'); // just runs validation

        // need to be able to check if form is valid here
        if (valid === true) {
            $validateError.hide();

            return paypal.rest.payment.create(env, client, {
                transactions: [
                    {
                        amount: { total: total, currency: 'USD' }
                    }
                ]
            });
        } else {
            $validateError.show();
            return false;
        }
    },
    commit: true,
    onAuthorize: function(data, actions) {
        return actions.payment.execute().then(function() {
            paypalDonation(data);
        });
    }
}, '#paypal-button');

0 个答案:

没有答案