首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >jqBootstrapValidation不是一个函数

jqBootstrapValidation不是一个函数
EN

Stack Overflow用户
提问于 2013-11-20 05:11:12
回答 2查看 4.9K关注 0票数 0

我有一个标准的.NET 4.5 Webforms应用程序。但是,一旦我包含了来自http://reactiveraven.github.io/jqBootstrapValidation/http://reactiveraven.github.io/jqBootstrapValidation/,我就会得到错误:

代码语言:javascript
复制
jqBootstrapValidation is not a function

在Firebug控制台中。我要怎么追踪这个?我包括我的网站管理员的相关部分:

代码语言:javascript
复制
<head runat="server">
    <meta charset="utf-8" />
    <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"> </script>
    <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"> </script>
    <link href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css" rel="stylesheet">
    <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.2/js/bootstrap.min.js"> </script>
    <script src="//raw.github.com/ReactiveRaven/jqBootstrapValidation/1.3.6/jqBootstrapValidation.js"></script>
</head>
<body data-spy="scroll" data-target="#NavbarLeft">
    <form novalidate class="form-horizontal" runat="server">
        <asp:ScriptManager runat="server" EnablePageMethods="True" EnableCdn="True">
            <Scripts>
                <%--Framework Scripts--%>
                <asp:ScriptReference Name="MsAjaxBundle" />
                <asp:ScriptReference Name="WebForms.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebForms.js" />
                <asp:ScriptReference Name="WebUIValidation.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebUIValidation.js" />
                <asp:ScriptReference Name="MenuStandards.js" Assembly="System.Web" Path="~/Scripts/WebForms/MenuStandards.js" />
                <asp:ScriptReference Name="GridView.js" Assembly="System.Web" Path="~/Scripts/WebForms/GridView.js" />
                <asp:ScriptReference Name="DetailsView.js" Assembly="System.Web" Path="~/Scripts/WebForms/DetailsView.js" />
                <asp:ScriptReference Name="TreeView.js" Assembly="System.Web" Path="~/Scripts/WebForms/TreeView.js" />
                <asp:ScriptReference Name="WebParts.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebParts.js" />
                <asp:ScriptReference Name="Focus.js" Assembly="System.Web" Path="~/Scripts/WebForms/Focus.js" />
                <asp:ScriptReference Name="WebFormsBundle" />
                <%--Site Scripts--%>
            </Scripts>
        </asp:ScriptManager>

然后在结束正文标记之前:

代码语言:javascript
复制
    </form>

    <%--//Comment this in once we can work out why it wont compile--%>
    <script>
        $(function () {
            $("input,select,textarea").not("[type=submit]").jqBootstrapValidation();
        });
    </script>
</body>
</html>

下面是App_Start注册捆绑包的相关代码.

代码语言:javascript
复制
public class BundleConfig
{
    public static void RegisterBundles(BundleCollection aBundles)
    {
        aBundles.Add(new ScriptBundle("~/Bundles/WebFormsJs").Include(
            "~/Scripts/WebForms/WebForms.js",
            "~/Scripts/WebForms/WebUIValidation.js",
            "~/Scripts/WebForms/MenuStandards.js",
            "~/Scripts/WebForms/Focus.js",
            "~/Scripts/WebForms/GridView.js",
            "~/Scripts/WebForms/DetailsView.js",
            "~/Scripts/WebForms/TreeView.js",
            "~/Scripts/WebForms/WebParts.js"));

        aBundles.Add(new ScriptBundle("~/Bundles/MsAjaxJs").Include(
            "~/Scripts/WebForms/MsAjax/MicrosoftAjax.js",
            "~/Scripts/WebForms/MsAjax/MicrosoftAjaxApplicationServices.js",
            "~/Scripts/WebForms/MsAjax/MicrosoftAjaxTimer.js",
            "~/Scripts/WebForms/MsAjax/MicrosoftAjaxWebForms.js"));

        // Use the Development version of Modernizr to develop with and learn from. Then, when you’re
        // ready for production, use the build tool at http://modernizr.com to pick only the tests you need
        aBundles.Add(new ScriptBundle("~/Bundles/modernizr").Include(
            "~/Scripts/modernizr-*"));
    }
}

我在这里遗漏了什么,我该如何解决?诊断这类“非函数”问题。

如果我没有任何受http://amanek.com/building-data-annotations-validator-control-with-client-side-validation/保护的字段,错误就会消失。

但我仍然不知道这会如何影响事物,因为这是使用纯JS在皮肤下。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-11-21 10:46:40

我计算出,在某些情况下,在页面中的两次和不同的位置添加了两次不引人注意的验证。

由于我没有使用不显着的验证,所以我用以下方法禁用了它:

代码语言:javascript
复制
<appSettings xdt:Transform="Replace">
    <add key="ValidationSettings:UnobtrusiveValidationMode" value="None"/>
</appSettings>
票数 1
EN

Stack Overflow用户

发布于 2013-11-20 05:14:47

你的剧本让我觉得很奇怪。例如,我认为:

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"> </script>

实际上应该是:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"> </script>

将所有的包含更改为后一种格式,看看这是否有帮助。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20087885

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档