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: { 开发者_如何学C 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();
}
});
精彩评论