简体   繁体   中英

jQuery validation not validating or submitting

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.

Use a submitHnadler insteadof a separate .ajaxForm.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM