0

I am trying to validate a select box using a remote resource when the select box is changed but the remote resource is not getting triggered:

这是代码:

$("#register_student_2").validate({
    submitHandler: function(form) {
        $(form).ajaxSubmit({
            rules: {
                relationship: {
                    required: true,
                    remote: function() {
                        return {
                            type: "POST",
                            url: "includes/check-relationship.php",
                        }
                    }
                },
            },
            beforeSubmit: function() {
                //do something
            },
            clearForm: true,
            success: function(data) {
            },
        });
    }
});
4

1 回答 1

1

rules必须传递给选项,而validate不是ajaxSubmit选项

$("#register_student_2").validate({
    rules: {
        relationship: {
            required: true,
            remote: function () {
                return {
                    type: "POST",
                    url: "includes/check-relationship.php",
                }
            }
        },
    },
    submitHandler: function (form) {
        $(form).ajaxSubmit({
            beforeSubmit: function () {
                //do something
            },
            clearForm: true,
            success: function (data) {},
        });
        return false;
    }
});
于 2013-05-27T12:19:29.883 回答