我“再次”询问 jQuery Validate 插件...
现在,我的问题是错误标签不会隐藏,直到我单击一次提交按钮并且需要第二次单击才能提交表单,知道吗?如果我的输入文本有效,我需要的是隐藏错误标签。
jQuery:
$("#form").validate({
rules: {
"name": {
required: true,
minlength: 3
},
"phone":{
required:true,
digits:true,
minlength: 9
},
"email":{
required: true
},
"storageoptions":{
required: true
},
"quantity":{
required:true,
digits:true
}
},
messages: {
"name": {
required: "Please enter a name"
},
"phone":{
required: "Required field"
},
"email":{
required: "Enter a valid email"
},
"storageoptions":{
required: "Please select an option"
},
"quantity":{
required: "This Field required"
}
},
errorPlacement: function(error, element) {
error.insertBefore(element);
},
submitHandler: function (form) {
$.ajax({
type: 'POST',
data: $(form).serialize(),
url: 'file.php',
success: function () {
form.reset();
$('#submit').hide();
$('#success-line').show().fadeOut(7000, function(){
$('#submit').show("slow");
});
}
});
return false;
}
});
这是我的演示:http: //jsfiddle.net/ujDC3/