MVC5 jQuery验证

时间:2015-02-10 22:03:53

标签: asp.net-mvc-5 jquery-validate

我在同一个MVC5应用程序中有2个页面,第一页jqueryval工作正常,而另一个页面没有。他们使用2个不同的_Layout页面,但所有引用的脚本和样式都是相同的,除非我是盲人。

这是工作视图

<head>
    <meta name="viewport" content="width=device-width" />
    <title>Registration</title>

    <!-- Custom CSS -->
    <link href="/Content/bower_components/dist/sb-admin-2.css" rel="stylesheet">
    <!-- Bootstrap Core CSS -->
    <link href="/Content/bower_components/bootstrap/dist/bootstrap.min.css" rel="stylesheet">
    <!-- MetisMenu CSS -->
    <link href="/Content/bower_components/metisMenu/dist/metisMenu.min.css" rel="stylesheet">
    <!-- Custom Fonts -->
    <link href="/Content/bower_components/fontawesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <link href="/Content/kendo/css?v=BRNdJQ-WO0tJDJizmw6veCLWmplb0_pVfAw25EB1cSo1" rel="stylesheet"/>


    <!-- jQuery -->
    <script src="/Scripts/bower_components/jquery/dist/jquery.min.js"></script>

    <!--Braintree-->
    <script src="https://js.braintreegateway.com/v2/braintree.js"></script>
    <script src="/bundles/kendo?v=8a-eVl9OWVi3D9bqkSvoiEAccYbkpGkrY2gmyFSb7zY1"></script>

</head>
<body>

... Removed for berevity.. can be added if needed

    <!-- Bootstrap Core JavaScript -->
    <script src="/Scripts/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
    <!-- Metis Menu Plugin JavaScript -->
    <script src="/Scripts/bower_components/metisMenu/dist/metisMenu.min.js"></script>
    <!-- Custom Theme JavaScript -->
    <script src="/Scripts/bower_components/dist/js/sb-admin-2.js"></script>


    <script src="/bundles/jqueryval?v=NOVQDySGO89wzMzO5x7mWS4C_uAdynpZe_Lk2y-xEM41"></script>

</body>
</html>

我有第二页,其中jqueryval Not Working

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>New Appointment</title>
    <script src="/bundles/modernizr?v=wBEWDufH_8Md-Pbioxomt90vm6tJN2Pyy9u9zHtWsPo1"></script>

    <!-- Bootstrap Core CSS -->
    <link href="/Content/bower_components/bootstrap/dist/bootstrap.min.css" rel="stylesheet">
    <!-- MetisMenu CSS -->
    <link href="/Content/bower_components/metisMenu/dist/metisMenu.min.css" rel="stylesheet">
    <!-- Timeline CSS -->
    <link href="/Content/bower_components/dist/timeline.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="/Content/bower_components/dist/sb-admin-2.css" rel="stylesheet">
    <!-- Custom Fonts -->
    <link href="/Content/bower_components/fontawesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <link href="/Content/kendo/css?v=BRNdJQ-WO0tJDJizmw6veCLWmplb0_pVfAw25EB1cSo1" rel="stylesheet"/>



    <link href="/Content/extras.css" rel="stylesheet" />

    <!-- Custom Fonts -->
    <link href="/Content/extras.css" rel="stylesheet" type="text/css">

    <!-- jQuery -->
    <script src="/Scripts/bower_components/jquery/dist/jquery.min.js"></script>

    <!--Braintree-->

    <script src="/bundles/kendo?v=8a-eVl9OWVi3D9bqkSvoiEAccYbkpGkrY2gmyFSb7zY1"></script>


</head>
<body>
... left out for berevity, but can be added if needed ...

<!-- Bootstrap Core JavaScript -->
<script src="/Scripts/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- Metis Menu Plugin JavaScript -->
<script src="/Scripts/bower_components/metisMenu/dist/metisMenu.min.js"></script>

<!-- Custom Theme JavaScript -->
<script src="/Scripts/bower_components/dist/js/sb-admin-2.js"></script>


    <script src="/bundles/jqueryval?v=NOVQDySGO89wzMzO5x7mWS4C_uAdynpZe_Lk2y-xEM41"></script>



<!-- Visual Studio Browser Link -->
<script type="application/json" id="__browserLink_initializationData">
    {"appName":"Chrome","requestId":"2e5209e5c8fc4291a24966678450e237"}
</script>
<script type="text/javascript" src="https://localhost:44399/394b2df3ceef431890edde525a8c014f/browserLink" async="async"></script>
<!-- End Browser Link -->

</body>
</html>

我尝试过很多不同的事情让他的工作和避风港找出问题所在。任何帮助都会很棒。

更新

你是对的我没有真正描述我急于开会的问题。描述我显示的2页是放置链接和脚本引用。在工作视图中,当我按下提交按钮时,jquery验证将触发,并且没有回发,因为表单无效。在不工作视图中,即使页面上有错误,我也会点击提交按钮,页面会完整回发。无论我或视图上的错误,验证jquery验证都不会触发。

0 个答案:

没有答案