我希望我的错误浮动在上面,左对齐,输入字段不验证。我怎样才能做到这一点?jQuery验证:如何不显示错误?或者如何将错误显示为工具提示?
如果我不能,我怎样才能关闭错误?我仍然希望字段验证(并突出显示错误),但不是要显示实际的错误消息。我似乎无法在jQuery文档中找到任何可让我将它们打开/关闭的东西......?
我希望我的错误浮动在上面,左对齐,输入字段不验证。我怎样才能做到这一点?jQuery验证:如何不显示错误?或者如何将错误显示为工具提示?
如果我不能,我怎样才能关闭错误?我仍然希望字段验证(并突出显示错误),但不是要显示实际的错误消息。我似乎无法在jQuery文档中找到任何可让我将它们打开/关闭的东西......?
您希望使用errorPlacement选项,并可能使用errorContainer和errorElement进一步自定义。
见http://docs.jquery.com/Plugins/Validation/validate#toptions
使用errorPlacement属性的jQuery验证电话,为J库珀建议:
$(...).validate({
errorPlacement: function(error, element) {
error.insertBefore(element);
}
});
和CSS样式的错误(在你的样式表,或者单个元素):
label.error {
/* Move the error above the input element. */
position: absolute;
line-height: 1.5em;
margin-top: -1.5em;
background-color: red;
color: white;
padding: 0 2px;
}
对于jQuery位:应该使用insertBefore()而不是before()。谢谢! – neezer 2009-06-19 15:43:52