jQuery验证未验证或提交 [英] jQuery validation not validating or submitting

查看:68
本文介绍了jQuery验证未验证或提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我关于此的第三篇文章,但是我一直在进行更改,因为没有一个答案可以完整地起作用(如果验证有效,则提交的结果无效,等等)

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.

使用此代码,它将无法验证.它不显示消息,它可以让我随时随地提交.当我提交时,它会隐藏div并显示另一个div,然后将所需的数据放在$ _POST中,但是它不能像预期的那样工作.

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);
}); 

并且没有验证.

推荐答案

使用commitHnadler代替单独的.ajaxForm.

Use a submitHnadler insteadof a separate .ajaxForm.

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

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

这篇关于jQuery验证未验证或提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆