Jquery验证和MVC2愚蠢的问题

时间:2011-08-25 13:04:22

标签: asp.net-mvc-2 asp.net-mvc-2-validation jquery-validate

我正在尝试在我的MVC2项目中进行一些基本的Jquery验证,并且我一直收到此错误......

Microsoft JScript运行时错误:对象不支持属性或方法'validate'

甚至在页面加载这个简单的脚本之前......

    $("#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>

1 个答案:

答案 0 :(得分:0)

Jquery和验证脚本需要在使用验证的所有页面中引用,此规则适用于所有javascript文件和css。

为避免重复引用,您可以将它们包含在母版页