[英]the custom message are not dsplayed in jquery validate plugin
I have a form which does validation with the help of Jquery validate
plugin.But i can't make the custom message to display for the necessary field.Could some one help me what i am doing wrong here. 我有一种表格可以通过
Jquery validate
插件来进行Jquery validate
但是我无法为必要的字段显示自定义消息。有人可以帮助我在这里做错什么吗。
$('#ph_form').validate({
'rules':{
'firstname':{
'required':true,
'lettersonly': true
},
'city':{
'required':true,
'lettersonly': true
},
},
'errorClass': "error",
'errorElement': "none",
'errorPlacement': function(error, element) {
element.parent().addClass('error');
},
'messages':{
'firstname': 'Please enter a valid email',
'city': 'Please enter a valid city',
},
submitHandler: function(form) {
$.ajax({
/*some code */
}
});
}
});
You can try adding error.insertAfter(element); 您可以尝试添加error.insertAfter(element);。
'messages':{
'firstname': 'Please enter a valid email',
'city': 'Please enter a valid city',
},
'errorClass': "error",
'errorElement': "none",
'errorPlacement': function(error, element) {
element.parent().addClass('error');
error.insertAfter(element); //Try adding this to your function
},
Hope this link might be helpful to you.Its clearly specified in the errorPlacement
section 希望此链接可能对您有所帮助。在
errorPlacement
部分中明确指定了此链接
http://jqueryvalidation.org/validate/ http://jqueryvalidation.org/validate/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.