<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"> </script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.15.0/jquery.validate.js"></script>
<script>
$(document).ready(function () {
$("#signupform").validate({
rules:{
email: {
required: true,
minlength: 10
},
password: {
required: true
},
password2: {
equalTo: "#password"
}
},
messages: {
email: "test"
}
});
});
</script>
上面是我的代码,用于调用我放置在 . 它一直说 $(...).validate 不是一个函数。
然后,我删除了这个:
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.15.0/jquery.validate.js"></script>
我直接将访问“http://ajax.aspnetcdn.com/ajax/jquery.validate/1.15.0/jquery.validate.js”得到的js代码放入<script></script>
内的头部,
验证方法应该现在必须存在,
但是,我仍然得到 $(...).validate 不是一个函数。
有人知道是什么原因导致这里出现问题吗?
最佳答案
非常感谢您的评论。
花了几个小时我终于找到了这个问题的原因: 应用了 sitemesh,它会自动在主体底部添加一个 jquery 脚本链接,从而使结果页面添加了 2 个 jquery,而我无法仅通过查看中的代码来找到添加的这个邪恶的额外 jquery。 IDE。
关于javascript - "$(...).validate is not a function"即使我直接将 jquery.validate.js 代码放在 head 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38238505/