时候,我得到了我的答案后。事实上,我想在输入字段的下一列(td)中显示带有标注(包含错误)的图像,但未通过验证插件进行验证。当一个输入字段被验证时,这个错误图像应该被删除,并在其上标注。
这是我的解决方案。
$("form").validate({
errorPlacement: function(error, element) {
//There should be an error
if(error.html() != ''){
element.parent().next().html("<img id='exclamation' src='images/exclamation.gif' />").callout({
width : 200,
cornerRadius : 8,
className : "validationCallout",
content : error,
align : "left",
nudgeHorizontal : -14,
nudgeVertical : 4,
arrowHeight : 6
});
}
},
success: function(label) {
$(obj).find(".valid").parent().next().html(""); //remove error image from next column(td) of input containing "valid" class
$(obj).find(".valid").parent().next().closeCallout(); //remove callout on error image from next column(td) of input containing "valid" class
}
});
此代码可能很复杂,但它现在对我来说很有用。这里使用了一个标注插件,它与问题无关,但可以帮助解决问题。 任何人都可以使它更简单吗?
您可能需要切换 $(obj).find(“。valid”)。parent()。next()。html(“”); $(OBJ).find( “有效”。)父()的next()closeCallout()。; ()“。”)。parent()。next().html(“”).closeCallout(); – 2009-08-11 13:19:01
谢谢。这很好。 – NAVEED 2009-08-12 07:23:41