3

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

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

SCRIPT65535: Unexpected call to method or property access. jquery.min.js, line 2 character 65772

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

但是,如果我忽略该错误,验证在 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>

没有你们的帮助,我目前无法完成这项工作,所以谢谢你们。

4

2 回答 2

1

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

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

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

于 2012-09-05T21:03:12.607 回答
0

好的,我永远无法真正深入了解这一点,但我发现了一些在 IE8 中没有错误的东西。

主要区别在于errorLabelContainer更改为表单的类而不是单个输入errorElement并被删除(我意识到不再需要它)。

wrapper: ".formwrapper",
keyup: false,
onfocusout: false,
onclick: false,
onchange: false,
errorLabelContainer: ".form",
errorClass: "incomplete",
于 2012-09-07T20:13:45.513 回答