html5表单验证在IE9中不起作用

时间:2016-12-21 17:29:45

标签: jquery html5 twitter-bootstrap-3

我正在尝试使用IE9进行表单验证。我可以使用基础知识,但表单验证不起作用。

在下面的代码中,下拉列表在IE9中工作正常,所以我知道bootstrap和jquery正在工作,但是表单不执行验证(即IE9中为空时,必填字段不会失败)。当我在IE11中运行它时一切都很好。

我假设html5 shiv with modernizr并且回应会解决这个问题。

有什么问题?

    <!DOCTYPE html>
    <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    </STYLE>
    <link href="css/bootstrap.css" rel="stylesheet">
    <script src="js/modernizr-2.6.2.js"></script>
    </head>
    <body>

    <div class="container" >
          <form class="form-signin"  METHOD="post" ACTION="agentLogin.asp">
            <h2 class="form-signin-heading">Portal login</h2>
            <label for="username" class="sr-only">User ID</label>
            <input type="email" id="username" name="username" class="form-control" placeholder="User ID" required autofocus>
            <label for="password" class="sr-only">Password</label>
            <input type="password" id="password" name="password" class="form-control" placeholder="Password" required>
            </div>
            <button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
          </form>
        </div>
    <div class = "dropdown">
       <button type = "button" class = "btn dropdown-toggle" id = "dropdownMenu1" data-toggle = "dropdown">
          Topics
          <span class = "caret"></span>
       </button>

       <ul class = "dropdown-menu" role = "menu" aria-labelledby = "dropdownMenu1">
          <li role = "presentation">
             <a role = "menuitem" tabindex = "-1" href = "#">Java</a>
          </li>

          <li role = "presentation">
             <a role = "menuitem" tabindex = "-1" href = "#">Data Mining</a>
          </li>

          <li role = "presentation">
             <a role = "menuitem" tabindex = "-1" href = "#">
                Data Communication/Networking
             </a>
          </li>

          <li role = "presentation" class = "divider"></li>

          <li role = "presentation">
             <a role = "menuitem" tabindex = "-1" href = "#">Separated link</a>
          </li>
       </ul>
    </div>
    <script src="js/jquery-3.1.1.js" type="text/javascript"></script>
    <script src="js/bootstrap.js"></script>
    <!--[if lt IE 9]>
     <script src="js/html5shiv.js" type="text/javascript"></script>
     <script src="js/respond.min.js" type="text/javascript"></script>
    <![endif]-->
    </BODY></HTML>

1 个答案:

答案 0 :(得分:0)

加入头:

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> <![endif]-->