我在让我的JQuery 验证达到我想要的地方时遇到了一些麻烦。我的错误显示在带有箭头的边栏中。这可以通过单个“包装器”来实现。
$('#loginform').validate({
errorPlacement: function(label, element) {
label.addClass('arrow');
label.insertAfter(element);
},
wrapper: 'span'
});
问题是不幸的是我的输入字段周围有一个框,所以错误应该放在那个框的边框上。为此,我需要两个包装器。所以我的错误应该是这样的:
<span class='errorContainer'>
<span class='arrow'>
<span class='error'>This is the actual error message.</span>
</span>
</span>
当前的代码只给了我这个:
<span class='arrow'>
<span class='error'>This is the actual error message.</span>
</span>