一旦我插入errorPlacement:
函数,它就会破坏代码。单击提交时不会进行验证。有人可以帮忙吗?
如果我删除此功能,验证工作正常。
进口:-
<script type="text/javascript" src="/MyApp/js/jquery.js"></script>
<script type="text/javascript" src="/MyApp/js/jquery.validate.min.js"></script>
脚本:-
$(document).ready(function(){
$("#post-an-ad").validate({
rules:{
articleTitle:{
required: true,
minlength: 5
},
dateRequested:{
required: true,
date: true
},
articleLocation:{
required: true,
minlength: 8
},
'user.agent': "required",
'user.firstName': "required",
'user.emailId':{
required: true,
email: true
},
'user.phone':{
required: true,
minlength: 8,
number: true
}
},
errorPlacement: function(error, element) {
alert("This alert is not popping");
},
submitHandler: function(form){
// doing nothing on a submit.
return false;
}
});
});