Stripe checkout
未验证required
输入字段。
必填字段:
<input type="tel" name="appointment[patient_phone]" id="appointment_patient_phone" required="required" placeholder="Phone Number">
当我点击stripe
时按钮,stripe checkout popup
出现并且表单未验证。
所以我尝试添加自定义验证器,但是 stopPropagation
不能像 stripe checkout popup
一样工作alert
之后仍然弹出和stopPropagation
被称为
function validateAppointmentForm() {
var validateForm = function(event) {
debugger;
var phone = $('#appointment_patient_phone').val();
if (!phone) {
alert("Phone number is required.");
event.preventDefault();
event.stopPropagation();
}
}
var watchStripeButton = function() {
debugger;
$("#new-appt-stripe-button").on("click", validateForm);
}
debugger;
watchStripeButton();
}
;
最佳答案
您应该使用Custom Checkout改为这里。这允许您拥有自己的按钮,并在打开 Checkout 之前向表单添加验证。
当客户点击您的按钮进行付款并输入其银行卡详细信息时,您会检测到某些字段未正确填写或具有无效值并显示错误。如果表单通过验证,您可以在点击处理程序中调用 handler.open()
。
关于javascript - stripe checkout 不验证必填字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35930807/