jQuery 验证在 IE7 中不起作用 + IE8

发布于 2024-11-06 01:22:56 字数 1507 浏览 0 评论 0原文

我正在尝试在我的网站上的表单上使用 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>

编辑:我们现在知道使用最新的 jquery,我使用的是 jQuery v1.6,这是问题所在。我改回 v1.5.2 并更改

var validator = $("form").validate ({

为:

$("form").validate ({

现在 IE 中一切正常。谢谢。

I'm trying to use the jQuery Validation plugin on a form on my website. The form works in FF, Chrome, Opera and Safari. It has yet to work in IE7 or IE8.

Below is a simplified version of my code that seems to work in every browser but 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>

Edit: We now know that using jquery latest, I was using jQuery v1.6, was the issue. I changed back to v1.5.2 and changed

var validator = $("form").validate ({

to:

$("form").validate ({

Everything is working in IE, now. Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

深海夜未眠 2024-11-13 01:22:56

我认为您要么需要返回到早期版本的 jquery (1.5.2),要么使用较新版本的 验证插件 1.8.0.1。

I think you either need to move back to an earlier version of jquery (1.5.2) or use the newer version of the validation plugin 1.8.0.1.

み格子的夏天 2024-11-13 01:22:56

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

jquery-1.5.1.min.js 
jquery.validate.min.js (which is version 1.8.0)

您可能想要做的第一件事是将 jquery 版本更新到最新版本,今天的版本是 < strong>1.7.1

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

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

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

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

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

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

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

When you create a new ASP.NET MVC 3 Project in Visual studio, your script folder will by default contain among others:

jquery-1.5.1.min.js 
jquery.validate.min.js (which is version 1.8.0)

One of the first things you might want to do is update the jquery version to the latest version, which today is version 1.7.1

After doing this, your client side validation will stop working in Internet Explorer 7 and Internet Explorer 8.

This is because the jquery.validate version is not compatible with jquery versions > 1.6. The solutions is simple, you need to update your version of jquery.validate as well.

You can find the current version 1.9 from Microsoft’s CDN or the latest version from GitHub here:

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

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

Remember that you can always find the latest javascript library in Microsofts CDN, see the complete list of available libraries here: http://www.asp.net/ajaxlibrary/cdn.ashx

This information is from my blog post about this problem

究竟谁懂我的在乎 2024-11-13 01:22:56

不管怎样,我必须升级到最新的 JQuery(此时为 1.8.2)和 Validate(1.10)才能解决这个问题。

For what it's worth, I had to upgrade to latest JQuery (1.8.2 at this time) and Validate (1.10) to get around this issue.

謌踐踏愛綪 2024-11-13 01:22:56

我在 IE7/IE8 中遇到了 jquery.validate.js 的问题。调试后,我注意到以下行导致了问题(版本 1.7 中的 ln 436):

return $([]).add(this.currentForm.elements)
            .filter(":input")

将这两行替换为:

return $(':input', this.currentForm)

这对我来说是成功的。

I had issues with jquery.validate.js in IE7/IE8. After debugging I noticed the following line was causing the issue (ln 436 in version 1.7):

return $([]).add(this.currentForm.elements)
            .filter(":input")

Replace these two lines with something like:

return $(':input', this.currentForm)

That did the trick for me.

无声无音无过去 2024-11-13 01:22:56

我刚刚遇到了这个问题,但问题不是我需要最新版本的 jquery——而是最新版本的 jquery 导致了这个问题。 Jquery 2.x 目前不支持 IE,因此请确保您使用的是 1.8+ 但低于 2.0。

I just had this issue but the problem was not that I needed the latest version of jquery--it was the latest version of jquery that caused the issue. Jquery 2.x does not support IE at this time, so make sure you're using 1.8+ but less than 2.0.

葵雨 2024-11-13 01:22:56

我在使用 jqueryui 自动完成的 Sage CRM 上遇到了同样的问题,仅在 IE(版本 10)中出现错误“script3:未找到成员。jquery-1.8.2.min.js,第 2 行字符 32075”。此错误与页面模式有关:IE 强制站点进入 IE 7 标准模式。

这是一个令人讨厌的黑客行为,但效果很好。将其放在页面的开头。今晚我花了一个小时搞乱这个,希望这对其他人有帮助。

<!DOCTYPE HTML>
<meta http-equiv="x-ua-compatible" content="IE=Edge">

I had the same problem on Sage CRM using jqueryui autocomplete getting error "script3: member not found. jquery-1.8.2.min.js, line 2 character 32075" only in IE (version 10). This error was tied up in the page mode: IE was forcing the site into IE 7 standard mode.

Its a nasty hack, but it works well. Put this at the start of the page. Cost me an hour tonight messing about with this, hope this helps someone else.

<!DOCTYPE HTML>
<meta http-equiv="x-ua-compatible" content="IE=Edge">
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文