2013-01-14 81 views
0

jQuery验证方法errorPlacement未触发。实际上,唯一触发的方法是showErrors。我想我错过了一些东西。代码如下。jQuery验证errorPlacement不起作用

errorContainer: '#error-messages', 
    showErrors: function (errors) { 
     $("#error-messages").dialog({ 
      modal: true, 
      title: 'Errors', 
      buttons: { 
       Ok: function() { 
        $(this).dialog("close"); 
       } 
      } 
     }); 
     return true; 
    }, 
    errorLabelContainer: "#error-messages ul", 
    wrapper: "li", 
    errorPlacement: function (error, element) { 
     if (element.attr('name') == 'a') {  
      error.appendTo($('#restErrorDate')); 
     } 
    }, 
    debug: true 
+0

的errorContainer并去除,留下下面的相关项目的所有错误:仍然不工作 –

+0

showErrors:功能(错误){ $(“#错误信息 “)对话框({ 模式:真, 标题: '错误', 按钮:{ 确定:函数(){$ (本).dialog(” 亲密“);} } }); 返回true; ('name')=='a'){ }, errorPlacement:function(error,element)if(element.attr('name')=='a'){ error.appendTo($('#restErrorDate')); } }, debug:true }); –

+0

在jsfiddle.net中创建一个演示...可以包含CDN版本的验证插件以启用它 – charlietfl

回答

0

相信errorLabelContainer将胜过errorPlacement。前者旨在在一个地方显示所有错误,使后者变得多余,因此不被使用。

在你的情况你是想在UL,其父母有ID=error-messages

+0

errorContainer和相关项目被删除以留下以下内容: –