jQuery 验证未验证或提交

发布于 2024-10-01 10:47:45 字数 1365 浏览 0 评论 0原文

这是我关于此的第 3 篇文章,但我一直在进行更改,因为没有一个答案能够完全发挥作用(如果验证有效,则提交无效,等等)。

    $("#order").validate({
        submitHandler: function(form) {
            $(form).ajaxSubmit();
            $("#aciu").show(1000);
            $("#duomenysdiv").hide(500);
        },

        rules: {
            vardas: "required",
            pavarde: "required",
            adresas: "required",
            telef: {
                required: true,
                digits: true
            },
            email: {
                required: true,
                email: true
            }
        },
        messages: {
            vardas: "Koks Jusu vardas?",
            pavarde: "Kokia Jusu pavarde?",
            adresas: "Kur Jus gyvenate?",
            telef: {
                required: "Koks Jusu telefono Nr.?",
                digits: "Telefono numeryje turetu buti tik skaitmenys"
            },
            email: {
                required: "Koks Jusu el. pašto adresas?",
                email: "Iveskite teisinga el. pašto adresa"
            }
        }
    });

我现在真的要疯了,但我不能'似乎没有让它发挥作用。我一整天都在为此苦苦挣扎。

使用此代码,它不会验证。它不显示消息,并且允许我随时提交。当我提交时,它隐藏该 div 并显示另一个 div,并将所需的数据放入 $_POST 中,但它没有像预期的那样工作。

提交以及提交后应该执行的操作完美地进行

$('#order').ajaxForm(function() { 
     $("#aciu").show(1000);
     $("#duomenysdiv").hide(500);
}); 

,无需验证。

This is my 3rd post about this, but I keep making changes, because none of the answers work in full (if the validation works, the submission doesn't, etc.)

    $("#order").validate({
        submitHandler: function(form) {
            $(form).ajaxSubmit();
            $("#aciu").show(1000);
            $("#duomenysdiv").hide(500);
        },

        rules: {
            vardas: "required",
            pavarde: "required",
            adresas: "required",
            telef: {
                required: true,
                digits: true
            },
            email: {
                required: true,
                email: true
            }
        },
        messages: {
            vardas: "Koks Jusu vardas?",
            pavarde: "Kokia Jusu pavarde?",
            adresas: "Kur Jus gyvenate?",
            telef: {
                required: "Koks Jusu telefono Nr.?",
                digits: "Telefono numeryje turetu buti tik skaitmenys"
            },
            email: {
                required: "Koks Jusu el. pašto adresas?",
                email: "Iveskite teisinga el. pašto adresa"
            }
        }
    });

I am really going crazy here now, but I just can't seem to make it work. I'm struggling with this all day.

With this code, it doesn't validate. It doesn't show the messages, and it lets me submit whenever I wish. When I submit, it hides the div and shows the other div, and places the required data in $_POST, but it doesn't work like it's supposed to.

The submission and the process what it's supposed to do after the submission works perfectly with just

$('#order').ajaxForm(function() { 
     $("#aciu").show(1000);
     $("#duomenysdiv").hide(500);
}); 

and no validation.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你与清晨阳光 2024-10-08 10:47:45

使用submitHnadler 而不是单独的.ajaxForm。

    $("#myform").validate({
    //your other code

 submitHandler: function(form) {
 form.submit();
 }
});

Use a submitHnadler insteadof a separate .ajaxForm.

    $("#myform").validate({
    //your other code

 submitHandler: function(form) {
 form.submit();
 }
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文