jquery - IE8 上带有 jQ​​uery 验证的表单 : this.appendChild(a) 错误

标签 jquery internet-explorer-8 validation

好的,我希望这是关于此表格的最后一个问题。它功能齐全,除了 IE8 上的一个错误,该错误似乎没有在任何地方记录(在这种情况下,我可以找到......)。

如果我在 IE9 的 IE8 模式下运行此表单,我会在开发工具中看到以下内容

SCRIPT65535:意外调用方法或属性访问。 jquery.min.js,第 2 行字符 65772

对应于jquery.min.js中的this.appendChild(a)

但是,如果我忽略该错误,验证在 IE8 中仍然有效。在 IE9、Chrome、Firefox 中完全没有问题。

我的验证码的功能片段...

<head>


<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.js"></script>


<style>

.incomplete {
    border: 1px solid red;
    }

</style>

<script type="text/javascript">
    //form validation start
   $(document).ready(function() {

   $("#form").validate({
        errorLabelContainer: "input",
        wrapper: ".form",
        keyup: false,
        onfocusout: false,
        onclick: false,
        onchange: false,
        errorElement: "input",
        errorClass: "incomplete",
        rules: {
            organization: {
                defaultInvalid: true,
                required: true,
                minlength: 2
                },
            firstname: {
                defaultInvalid: true,
                required: true,
                minlength: 2
                },
            lastname: {
                defaultInvalid: true,
                required: true,
                minlength: 2
                },
            email: {
                defaultInvalid: true,
                required: true,
                email: true
                },
            phone: {
                defaultInvalid: true,
                required: true,
                minlength: 10
                },
        }
    });
   }); 
</script>

</head>
<body>

<div id="border">
    <div id="form_title">REQUEST INFO</div>
    <form id="form" name="form_container" action="#">
        <!-- fields -->
        <input id="organization" type="text" name="organization" />
        <input id="firstname" type="text" name="firstname" />
        <input id="lastname" type="text"  name="lastname" />
        <input id="email" type="text" name="email" />
        <input id="phone" type="text" name="phone" />
        <!-- submit button -->
        <input id="button" name="submit" class="button" type="submit" value="submit" /> 
    </form>
</div>

</body>
</html>

如果没有你们的帮助,我到目前为止不可能完成这项工作,所以谢谢你们。

最佳答案

不确定这是否有帮助,但您有一个小语法错误:

phone: {
            defaultInvalid: true,
            required: true,
            minlength: 10
            },

注意多余的逗号。它是列表中的最后一个,不需要它。 appendChild 可能在此逗号后使用空白规则,这就是错误?

关于jquery - IE8 上带有 jQ​​uery 验证的表单 : this.appendChild(a) 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12289675/

相关文章:

javascript - 使用下一个和上一个按钮分页,使用 jQuery 在 HTML 表格中加载时仅显示 5 页

javascript - 基于http或https协议(protocol)动态加载javascript

Java Spring : how to validate only specific fields from my entity

javascript - 将数组的第一项连接到第二个数组 JavaScript 的第一项

javascript - 嵌套 ng-repeat $first 和 $last?

php - 从 php 页面在 mysql 表中插入 jquery var 时,我遇到了一件非常奇怪的事情

javascript - window.print()IE 8崩溃

javascript - Mootools 1.3.2 & IE8 仅错误,对象不支持属性/方法

ruby-on-rails - 如何在 ruby​​ 中对我的模型进行全局验证(仅接受字母数字)

ruby-on-rails - Rails 中的日期验证