只要用jquery validate提交验证一次后,错误提示一直存在.
下面这段代码是当一提交的表单值为空时,就会出现提示错误.
现在提示错误也出来了,都正常.就是一旦提交一次后,那错误信息就会一直在页面存在着,不会自动消失.
我想做的判断是,当鼠标移到其它焦点后,这个错误信息就会自动消失隐藏掉.
希望高手,能告知一下...
HTML主要代码如下:
HTML
<form method="post" action="index.php?ac=search&at=list" name="search" id="search">
<input type="text" name="keyword" title="Search" class="searchinput" id="keyword" size="10"/> <input type="image" class="searchaction" />
</form>
$().ready(function() {
$("#search").validate({
rules: {
keyword: {
required: true,
minlength: 2
}
},
messages: {
keyword: {
required: "请输入关键字",
minlength: "不能少于两个字符"
}
}
});
});
$().ready(function() {
$("#search").validate({
onfocusout: false,
onkeyup: false,
onclick: false,
rules: {
keyword: {
required: true,
minlength: 2
}
},
messages: {
keyword: {
required: "请输入关键字",
minlength: "不能少于两个字符"
}
},
showErrors: function(errorMap, errorList) {
this.defaultShowErrors();
for(var i = 0; i < errorList.length; i++) {
$(errorList[i].element).one("blur", function() {
$("label.error[for='" + (this.id ? this.id : this.name) + "']").remove();
});
}
}
});
});