0

我在我的演示页面上使用了jQuery Validate插件,并且由于某种原因,提交按钮在谷歌浏览器中无法使用。我怀疑它与自动填充功能有关,但我不确定:表单提交按钮无法在谷歌浏览器工作(jQuery验证)

一直在为这个问题苦苦挣扎几天。

这里的链接:Contact Form

这里是jQuery代码的片段。文件中使用的所有js可以在以下位置找到:combined js code - 初始化程序代码位于底部。

$(function(){ 
/* ----- Validation ----- */ 
$("#contactform").validate({ 
    rules: { 
     email: { 
      required: true, 
      email: true 
     }, 
     name: "required", 
     last: "required", 
     phone: { 
      required: true, 
      phoneUS: true, 
      minlength: 10, 
      maxlength: 14 
     }, 
     city: "required", 
     state: "required", 
     zip: { 
      required: true, 
      minlength: 5, 
      maxlength: 10 
     }, 
     testimonial: { 
      required: true, 
      minlength: 5 
     }, 
     security_code: "required" 
    }, 

    submitHandler: function(form) { 
     form.submit(); 
     return false; 
    }, 

    messages: { 
     email: "<span class='errors'>Please enter a valid email address</span>", 
     name: { 
      required: "<span class='errors'>Please enter your first name</span>" 
     }, 
     last: { 
      required: "<span class='errors'>Please enter your last name</span>" 
     }, 
     phone: { 
      required: "<span class='errors'>Please enter your phone number</span>", 
      phoneUS: "<span class='errors'>Please enter a valid phone number</span>", 
      minlength: "<span class='errors'>Phone number too short</span>", 
      maxlength: "<span class='errors'>Phone number too long</span>" 
     }, 
     city: "<span class='errors'>Please enter your city</span>", 
     state: "<span class='errors'>Please choose your state</span>", 
     zip: { 
      required: "<span class='errors'>Please enter your zip code</span>", 
      minlength: "<span class='errors'>Zip Code must be more than 4 characters</span>", 
      maxlength: "<span class='errors'>Zip Code must be less than 11 characters</span>" 
     }, 
     testimonial: { 
      required: "<span class='errors'>Please enter your testimonial</span>", 
      minlength: "<span class='errors'>Testimonial must be more than 5 characters</span>" 
     }, 
     security_code: "<span class='errors'>This field is required</span>" 
    }, 

    errorPlacement: function(error, element) { 
     if (element.attr('id') != 'security_code_input') { 
      error.insertAfter(element); 
     } else { 
      error.insertAfter($('#sec_code_msg')); 
     } 
    } 
}); 


/* ----- Input Masking ----- */ 
$("#phone").mask("(999) 999-9999"); 

});

回答

3
<input name="submit" type="submit" value="Send Now"> 

这一行已覆盖窗体的“提交”功能,并用按钮代替它。

form.submit =此按钮。不是事件处理程序。

修正:将按钮命名为别的东西。

0

我怀疑窗体动作有问题.... ??

<form action="/contact_form_10-6-2011/contact.php#contactformWrapper" method="post" name="form1" id="contactform"> 

邓知道为什么,但我发现它扰乱了我。

是否使用相同的PHP文件中读取&解析输入以及??类似的东西,Using PHP_SELF in the action field of a form

+0

尝试使用只锚,它仍然无法正常工作。我正在使用:<?php echo $ _SERVER ['PHP_SELF']。 '#contactformWrapper'; ?> – Julian 2011-06-10 18:37:38

相关问题