jQuery验证无法在IE7 + IE8中运行

mag*_*lez 37 jquery internet-explorer jquery-validate internet-explorer-8 internet-explorer-7

我正在尝试在我的网站上的表单上使用jQuery Validation插件.该表单适用于FF,Chrome,Opera和Safari.它还没有在IE7或IE8中工作.

下面是我的代码的简化版本,似乎适用于每个浏览器,但IE.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">

<title>Form</title>

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.8/jquery.validate.js"></script>

<script type="text/javascript">
    $(document).ready(function(){
       var validator = $("form").validate ({
       rules: {
                first_name: "required"
              },
       messages: {
                first_name: "Enter your firstname"
                 }
       });
    });
</script>

</head>

<body>

<form method="post">
    <label for="first_name" class="hide">First Name</label> 
    <input type="text" name="first_name" value="" id="first_name" class="required" />
    <button type="submit" id="submit" name="submit">Submit</button>
</form>

</body>

</html>
Run Code Online (Sandbox Code Playgroud)

编辑:我们现在知道使用jquery最新,我使用jQuery v1.6,是问题.我改回到v1.5.2并改变了

var validator = $("form").validate ({
Run Code Online (Sandbox Code Playgroud)

至:

$("form").validate ({
Run Code Online (Sandbox Code Playgroud)

现在一切都在IE中运行.谢谢.

red*_*are 43

我想你要么需要回到早期版本的jquery(1.5.2),要么使用更新版本的验证插件1.8.0.1.

  • @Kieran Andrews尝试回购https://github.com/jzaefferer/jquery-validation/ (3认同)

Sti*_*ian 16

在Visual Studio中创建新的ASP.NET MVC 3项目时,默认情况下,您的脚本文件夹将包含以下内容:

jquery-1.5.1.min.js 
jquery.validate.min.js (which is version 1.8.0)
Run Code Online (Sandbox Code Playgroud)

您可能要做的第一件事就是将jquery版本更新到最新版本,现在版本为1.7.1

执行此操作后,您的客户端验证将停止在Internet Explorer 7和Internet Explorer 8中工作.

这是因为jquery.validate版本与jquery版本> 1.6不兼容.解决方案很简单,您还需要更新您的jquery.validate版本.

您可以在此处找到Microsoft的CDN当前版本1.9或GitHub的最新版本:

Microsoft Ajax CDN:http: //ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js

GitHub Jquery验证:https: //github.com/jzaefferer/jquery-validation/downloads

请记住,您始终可以在Microsofts CDN中找到最新的JavaScript库,请在此处查看可用库的完整列表:http://www.asp.net/ajaxlibrary/cdn.ashx

此信息来自我的博客文章,关于此问题


ozz*_*ozz 5

对于它的价值,我必须升级到(此时1.8.2)最新的jQuery和验证(1.10)来解决这个问题.