条带结帐不验证必填字段

stripe checkout doesn't validate required fields

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 popupalertstopPropagation 被调用后仍然弹出

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。这使您可以拥有自己的按钮并在打开结帐之前向表单添加验证。

当客户点击您的付款按钮并输入他的银行卡详细信息时,您会检测到某些字段未正确填写或具有无效值并显示错误。如果表单通过验证,您可以在点击处理程序中调用 handler.open()