Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript JQuery在提交前询问_Javascript_Jquery - Fatal编程技术网

Javascript JQuery在提交前询问

Javascript JQuery在提交前询问,javascript,jquery,Javascript,Jquery,我有一个表单,用户将在其中键入他的姓名(必填)、dob(非必填),在提交表单之前,有一个确认,表明他/她是否确定提交没有dob的表单。我正在使用一个模态从那里它将提交上述表格。我已经尝试运行下面的代码,但我看不出为什么不工作的问题。当dob中没有值时,模态应询问并说“没有dob,可以继续吗?”如果用户单击提交按钮,则应提交上述超出模态的表单。我希望你们能帮助我。多谢各位 HTML 您的submitHandler函数错误。试试这个代码,希望它能工作 $(document).bind("click"

我有一个表单,用户将在其中键入他的姓名(必填)、dob(非必填),在提交表单之前,有一个确认,表明他/她是否确定提交没有dob的表单。我正在使用一个模态从那里它将提交上述表格。我已经尝试运行下面的代码,但我看不出为什么不工作的问题。当dob中没有值时,模态应询问并说“没有dob,可以继续吗?”如果用户单击提交按钮,则应提交上述超出模态的表单。我希望你们能帮助我。多谢各位

HTML


您的
submitHandler
函数错误。试试这个代码,希望它能工作

$(document).bind("click", function (e) {
    $("#createexperience").validate({
        rules: {
            "language[]": {
                required: !0
            }
        }
        , messages: {}
        , submitHandler: function () {
            return !1
        }
        , ignore: ".ignore"
        , errorElement: "label"
        , errorClass: "has-error"
        , submitHandler: function (e) {
            if ($.trim($('#namefield').val()) == '') {
               $('#portfoliomsgmodal').modal('show');
               $('#submitlater').click(function () {
                  e.submit();
               });
           } else {
             e.submit();
           }
        }
        , highlight: function (e) {
            $(e).closest(".form-group").removeClass("success").addClass("has-error")
        }
    })
});

你能设置JSFIDLE这个表单吗?@bRIMOs我想使用modal提交表单(id=“createexperience”)button@Dinesh我很快就会提供它。@Dinesh我试图创建jsfiddle。但它没有打开模式。对于我的本地模式,模式正在工作,但模式上的提交按钮不工作。我更新了问题的更多细节,请帮助我解决。欢迎随时:)
$(document).bind("click", function (e) {
    $("#createexperience").validate({
        rules: {
            "language[]": {
                required: !0
            }
        }
        , messages: {}
        , submitHandler: function () {
            return !1
        }
        , ignore: ".ignore"
        , errorElement: "label"
        , errorClass: "has-error"
        , submitHandler: function (e) {
            if ($.trim($('#namefield').val()) == '') {
                if (jQuery('#submitlater').data('clicked')) {
                    $('#createexperience').submit();
                    e.submit();
                }
                else {
                    $('#portfoliomsgmodal').modal('show');
                    return false;
                }
            }
            else {
                e.submit();
            }
        }
        , highlight: function (e) {
            $(e).closest(".form-group").removeClass("success").addClass("has-error")
        }
    })
})
$(document).bind("click", function (e) {
    $("#createexperience").validate({
        rules: {
            "language[]": {
                required: !0
            }
        }
        , messages: {}
        , submitHandler: function () {
            return !1
        }
        , ignore: ".ignore"
        , errorElement: "label"
        , errorClass: "has-error"
        , submitHandler: function (e) {
            if ($.trim($('#namefield').val()) == '') {
               $('#portfoliomsgmodal').modal('show');
               $('#submitlater').click(function () {
                  e.submit();
               });
           } else {
             e.submit();
           }
        }
        , highlight: function (e) {
            $(e).closest(".form-group").removeClass("success").addClass("has-error")
        }
    })
});