0
$("#da-ex-validate2").validate({
                rules: {
                    details: {
                        required: true,
                        rangelength: [1, 500]
                    },
                    editor1: {
                        required: true,
                        minlength: 1
                    },
                    title: {
                        required: true,
                        rangelength: [1, 100]
                    },
                    SlideDeckPhoto: {
                        required: "#iButton:checked",
                        accept: ['.jpeg', '.png', '.jpg', '.gif']
                    },
                    min1: {
                        required: true,
                        digits: true,
                        min: 5
                    },
                    max1: {
                        required: true,
                        digits: true,
                        max: 5
                    },                          
                    submitHandler: function(form) {
                        $(form).ajaxSubmit();
                    },
                    range1: {
                        required: true,
                        digits: true,
                        range: [5, 10]
                    }

                },
                invalidHandler: function (form, validator) {
                    var errors = validator.numberOfInvalids();
                    if (errors) {
                        var message = errors == 1
                        ? 'You missed 1 field. It has been highlighted'
                        : 'You missed ' + errors + ' fields. They have been highlighted';
                        $("#da-ex-val2-error").html(message).show();
                    } else {
                        $("#da-ex-val2-error").hide(); // it's not work !!! and the page is reload !!
                    }
                }
            });

我还想在不重新加载页面的情况下将表单值保存到 MySql。请帮忙 !我读了很多帖子,尝试了很多东西!如果你放了一个代码,请告诉它放在哪里..顺便说一句,我的表单输入字段很少,还有一个文件输入字段。请帮忙 !

4

2 回答 2

0

从提交处理程序返回 false

submitHandler: function(form) {
    $(form).ajaxSubmit();
    return false;
}
于 2013-10-08T15:51:30.163 回答
0

这是我的解决方案,放在 invalidHandler 之后:

            submitHandler: function(form) {
                var dataString = $('#YourFormID').serialize();
                $.ajax({
                    type: 'POST',
                    url: 'yourpage.php',
                    data: dataString,
                    success:  function() {
                        $('#YourErrorDivID').hide();
                        $('#YourSuccessDivID').html("Your Message").show();
                    }
                });
            }
于 2013-10-09T07:59:01.153 回答