jQuery验证errorPlacement参数

jQuery验证errorPlacement参数,jquery,jquery-validate,Jquery,Jquery Validate,我尝试使用errorPlacement选项,如下所示: $("#MyForm").validate({ rules: { 'brand': { required: true, errorPlacement : function(error, element){ console.log(error);

我尝试使用errorPlacement选项,如下所示:

 $("#MyForm").validate({
            rules: {
                'brand': {
                    required: true,
                    errorPlacement : function(error, element){
                        console.log(error);
                        console.log(element);
                        error.appendTo(element.parent('div.formRight'));
                        error.css("clear", "both");
                    }
                }
但由于某些原因,函数只接收一个参数(元素)。。。在控制台日志中,错误参数中有元素引用,而元素参数未定义

是否有引用错误元素的特定方法


感谢正确使用
errorPlacement
回调函数,它只是另一个类似
规则的选项。换句话说,您不会将
errorPlacement
放在
规则的内部
;相反,它是
规则
的兄弟,并在全球范围内应用

$("#MyForm").validate({
        rules: {
            brand: {
                required: true
            }
        },
        errorPlacement: function(error, element) {
            console.log(error);
            console.log(element);
            error.appendTo(element.parent('div.formRight'));
            error.css("clear", "both");
        },
        // any other options
});