【问题标题】:Prevent Gravity Forms Submission With Confirmation Box使用确认框防止重力表格提交
【发布时间】:2014-12-08 09:01:28
【问题描述】:

当点击 WordPress Gravity Form 的提交按钮时,我正在使用以下代码输出一个确认框:

$(".gform_wrapper.form-01 form").submit(function(event) {

    confirm('Ut in nulla enim. Phasellus molestie magna non est bibendum non venenatis nisl tempor. Suspendisse.');

});

弹出窗口工作正常,但如果用户单击“取消”按钮,我需要它来阻止表单提交。但无论在确认中点击哪个按钮,表单都会提交。

【问题讨论】:

    标签: jquery wordpress forms gravity-forms-plugin


    【解决方案1】:

    设法自己修复它(一次!)

    $('.gform_wrapper.form-01 form input[type="submit"]').click(function(event) {
    
            event.preventDefault();
    
            var c = confirm('Ut in nulla enim. Phasellus molestie magna non est bibendum non venenatis nisl tempor. Suspendisse.');
    
            if (c == true) {
                $(this).closest('form').submit();
            } else {
                alert('no');
            }
    
        });
    

    【讨论】:

      猜你喜欢
      • 2016-07-18
      • 2017-07-21
      • 1970-01-01
      • 2011-10-13
      • 1970-01-01
      • 2018-03-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多