jQuery Validate和ajaxSubmit不能与IE8,IE9一起使用

时间:2013-08-12 11:41:47

标签: jquery ajax jquery-validate jquery-forms-plugin

我有以下表格可以在IE7和所有Safari,Chrome,Firefox中使用,但它不能在IE8和IE9中运行。它正确显示了成功消息,但实际上并没有提交任何内容。

我想知道是否有人知道这方面的解决方案?

这是我的表格和脚本;

<div id="successMessage" style="display:none;"><p>Thank you for contacting Fussey Engineering. We will contact you within 2 business days.</p></div>

<form method="post" action="" id="contactform">

<label for=name accesskey=U><span class="required">*</span> Your Name</label>
<input name="name" type="text" id="name" size="30" value="" />

<br />
<label for=email accesskey=E><span class="required">*</span> Email</label>
<input name="email" type="text" id="email" size="30" value="" />

<br />
<label for=phone accesskey=P><span class="required">*</span> Phone Number</label>
<input name="phone" type="text" id="phone" size="30" value="" />

<br />

<label for=comments accesskey=C><span class="required">*</span> Your Comments</label>
<textarea name="comments" cols="26" rows="8" id="comments"></textarea>

<hr />

<p style="margin:0px; padding:0px;"><span class="required">*</span>Are You Human?</p>

<label for=verify accesskey=V>3 + 1 =</label>
<input name="verify" type="text" id="verify" size="6" value="" />

<input name="contactus" type="submit" class="submit" id="contactus" value="Submit" />

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

    $.validator.addMethod("verify", function (value, element, params) {
        return value == params[0] + params[1];
    }, jQuery.validator.format("Please enter the correct value for {0} + {1}"));

    $("#contactform").validate({

        success: function(label) {
                label.hide();
        },
        rules: {
            name: {required: true},
            email: {
              email: true,
              required: true
            },
            phone: {
              required: true,
              digits: true
            },
            comments: {required: true},
            verify:{
              verify:[3, 1]
            }
        },
        messages: {
            name: "Please tell us your Name",
            email: "Please enter a valid email address",
            phone: "Please enter a valid phone number",
            comments: "Please enter your comments"
        },
        submitHandler: function(form) {
            $("#contactform").ajaxSubmit({
              success:function(e){
                $("#successMessage").show();
              }
            });
            return false;
        }
    });

});
</script>

0 个答案:

没有答案