jQuery(...).validate不是函数 [英] jQuery (...).validate is not a function
本文介绍了jQuery(...).validate不是函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的浏览器控制台告诉我:
My browser console is telling me that:
$(...).validate is not a function
我只是想重现此示例,但是它不起作用,我也不知道为什么.查看网络控制台,我发现没有文件加载错误.另外,我的缓存是清除的并且已关闭,因此我应该寻找正确的源.还有什么可能出问题了?
I am simply trying to reproduce this example, but it is not working, and I've no idea why. Looking at the networking console, I see that there is no file load error. Also my cache is clear and turned off, so I should be looking at the right source. What else could be going wrong?
这是页面上的完整代码:
Here's the full code on the page:
<form id="myform">
<input type="text" name="field1" />
<br/>
<input type="text" name="field2" />
<br/>
<input type="submit" />
</form>
<script src="jquery-1.8.3.min.js"></script>
<script>
$(document).ready(function () {
$('#myform').validate({ // initialize the plugin
rules: {
field1: {
required: true,
email: true
},
field2: {
required: true,
minlength: 5
}
},
submitHandler: function (form) { // for demo
alert('valid form submitted'); // for demo
return false; // for demo
}
});
});
</script>
推荐答案
您需要包括jQuery验证插件:
You need to include jQuery validation plugin:
<script type="text/javascript" src="path-to/jquery-validate.js"></script>
下载它并附加到您的项目.
download it and attach to your project.
这篇关于jQuery(...).validate不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文