我需要点击Paypal智能按钮来验证表单。下面的代码对我不起作用。
paypal.Buttons({
// onInit is called when the button first renders
onInit: function(data, actions) {
// Disable the buttons
actions.disable();
// Listen for changes to the checkbox
document.querySelector('#check')
.addEventListener('change', function(event) {
// Enable or disable the button when it is checked or unchecked
if (event.target.checked) {
actions.enable();
} else {
actions.disable();
}
});
},
// onClick is called when the button is clicked
onClick: function() {
// Show a validation error if the checkbox is not checked
if (!document.querySelector('#check').checked) {
document.querySelector('#error').classList.remove('hidden');
}
}
}).render('#paypal-button-container');