【问题标题】:bootstrapValidator Validator Not Working due to Javascript conflicts?bootstrapValidator 验证器由于 Javascript 冲突而无法工作?
【发布时间】:2015-01-31 18:52:44
【问题描述】:

我正在使用 Bootstrap Validator(bootstrapValidator.js) 进行表单验证。有了这个,我将 jQuery UI Multiselect component 添加到我的引导页面中。但是这个组件需要 1.5.1/jquery.min.js 并且 Bootstrap Validator 需要 jquery-1.10.2.min.js,因为这两个不同的版本在同一个页面上验证器是不工作的。如果我只使用 Js 的更新版本(jquery-1.10.2.min.js),那么 Multiselect 组件将停止工作。请帮忙....

【问题讨论】:

  • 您是否尝试仅保留 1.10.2 版本?通常没有太多东西可能真正需要旧版本的 jquery

标签: javascript php jquery twitter-bootstrap-3


【解决方案1】:

尝试按顺序添加文件:

  1. js/jquery-1.10.2.min.js
  2. js/jquery-ui.js(如果项目中存在文件:))
  3. jquery.min.js (1.5.1)
  4. js/bootstrap.min.js(如果项目中存在文件:))
  5. js/bootstrapValidator.min.js(如果项目中存在文件:))
  6. 其他js

如果它不起作用http://api.jquery.com/jQuery.noConflict/

【讨论】:

    【解决方案2】:

    您是否尝试过在 head 标签中包含所有 js 和 css 文件,并且包含顺序很关键:首先包含 jquery 库,下一个引导程序,下一个验证器插件。然后检查您的 html 代码是否有错误。我在网上找到了这个教程 [http://www.jqueryscript.net/form/Powerful-Form-Validation-Plugin-For-jQuery-Bootstrap-3.html]

    <head>
        <!-- <link rel="stylesheet" href="css/Style_sheet.css" type="text/css" /> -->
        <title>The Transformers</title>
        <link rel="icon" href="/title_icon2.jpg">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
        <!-- // <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script> -->
    
    
        <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
        <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
        <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
        <script src="http://getbootstrap.com/assets/js/docs.min.js"></script>
    
        <link rel="stylesheet" href="//cdn.jsdelivr.net/jquery.bootstrapvalidator/0.5.1/css/bootstrapValidator.min.css"/>
        <script type="text/javascript" src="//cdn.jsdelivr.net/jquery.bootstrapvalidator/0.5.1/js/bootstrapValidator.min.js"></script>
    
    </head>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-12-01
      • 1970-01-01
      • 2022-06-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-24
      • 1970-01-01
      相关资源
      最近更新 更多