Jquery 验证和 MVC2 愚蠢的问题
我正在尝试在我的 MVC2 项目中进行一些基本的 Jquery 验证,但我不断收到此错误...
Microsoft JScript 运行时错误:对象不支持属性或方法“验证”
即使在页面加载此简单脚本之前...
$("#temp1").validate({
rules: {
HospitalFinNumber: {
required: true,
minlength: 6
},
AdminDate: { requried: true }
}
});
temp1 是我的表单的 id,在该表单中有 HospitalFinNumber 的 id,依此类推... 知道会发生什么吗?这是我包含在 site.master 中的 js 文件
<link href="<%=ResolveClientUrl("~/Content/Site.css")%>" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="<%=ResolveClientUrl("~/Content/jqUIcss/jquery-ui-1.8.15.custom.css")%>" />
<link rel="stylesheet" type="text/css" media="screen" href="<%=ResolveClientUrl("~/Content/jqGrid/ui.jqgrid.css")%>" />
<script src="<%=ResolveClientUrl("~/Scripts/js/jquery-1.6.2.min.js")%>" type="text/javascript"></script>
<script src="<%=ResolveClientUrl("~/Scripts/js/jquery-ui-1.8.15.custom.min.js")%>" type="text/javascript"></script>
<script src="<%=ResolveClientUrl("~/Scripts/lib/jquery.metadata.js")%>" type="text/javascript"></script>
<script src="<%=ResolveClientUrl("~/Scripts/jquery.validate.js")%>" type="text/javascript"></script>
<script src="<%=ResolveClientUrl("~/Scripts/jquery.validate.min.js")%>" type="text/javascript"></script>
<script src="<%=ResolveClientUrl("~/Scripts/jquery.jqGrid.min.js")%>" type="text/javascript"></script>
<script src="<%=ResolveClientUrl("~/Scripts/grid.locale-en.js")%>" type="text/javascript"></script>
<script src="<%=ResolveClientUrl("~/Scripts/grid.base.js")%>" type="text/javascript"></script>
<script src="<%=ResolveClientUrl("~/Scripts/grid.tbltogrid.js")%>" type="text/javascript"></script>
<script src="<%=ResolveClientUrl("~/Scripts/jqDnR.js")%>" type="text/javascript"></script>
<script src="<%=ResolveClientUrl("~/Scripts/grid.common.js")%>" type="text/javascript"></script>
I am trying to do some basic Jquery Validation in my MVC2 project and I keep getting this error...
Microsoft JScript runtime error: Object doesn't support property or method 'validate'
Even before the page loads at this simple script...
$("#temp1").validate({
rules: {
HospitalFinNumber: {
required: true,
minlength: 6
},
AdminDate: { requried: true }
}
});
temp1 is the id of my form, in that form there are id's for HospitalFinNumber, and so on and so forth...
Any idea what could be going on? Here are the js files I have included in my site.master
<link href="<%=ResolveClientUrl("~/Content/Site.css")%>" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="<%=ResolveClientUrl("~/Content/jqUIcss/jquery-ui-1.8.15.custom.css")%>" />
<link rel="stylesheet" type="text/css" media="screen" href="<%=ResolveClientUrl("~/Content/jqGrid/ui.jqgrid.css")%>" />
<script src="<%=ResolveClientUrl("~/Scripts/js/jquery-1.6.2.min.js")%>" type="text/javascript"></script>
<script src="<%=ResolveClientUrl("~/Scripts/js/jquery-ui-1.8.15.custom.min.js")%>" type="text/javascript"></script>
<script src="<%=ResolveClientUrl("~/Scripts/lib/jquery.metadata.js")%>" type="text/javascript"></script>
<script src="<%=ResolveClientUrl("~/Scripts/jquery.validate.js")%>" type="text/javascript"></script>
<script src="<%=ResolveClientUrl("~/Scripts/jquery.validate.min.js")%>" type="text/javascript"></script>
<script src="<%=ResolveClientUrl("~/Scripts/jquery.jqGrid.min.js")%>" type="text/javascript"></script>
<script src="<%=ResolveClientUrl("~/Scripts/grid.locale-en.js")%>" type="text/javascript"></script>
<script src="<%=ResolveClientUrl("~/Scripts/grid.base.js")%>" type="text/javascript"></script>
<script src="<%=ResolveClientUrl("~/Scripts/grid.tbltogrid.js")%>" type="text/javascript"></script>
<script src="<%=ResolveClientUrl("~/Scripts/jqDnR.js")%>" type="text/javascript"></script>
<script src="<%=ResolveClientUrl("~/Scripts/grid.common.js")%>" type="text/javascript"></script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Jquery和验证脚本需要在所有使用验证的页面中引用,此规则适用于所有javascript文件和css。
为了避免重复引用,您可以将它们包含在母版页中
Jquery and validation scripts need to be reference in all pages where the validation is use, this rule applies to all javascript files and css.
To avoid repeat the reference you can include them in masterpage