Jquery 验证和 MVC2 愚蠢的问题

发布于 2024-12-01 03:58:42 字数 2181 浏览 0 评论 0原文

我正在尝试在我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

红衣飘飘貌似仙 2024-12-08 03:58:42

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文