2011-06-02 97 views
1

我有一个简单的表格:jQuery验证不点火submitHandler

<form method="post" action="/home/keepintouch" id="stay-in-touch"> 
       <div> 
       <label for="email">Stay in touch</label> 
       <input type="text" value="enter your email address" title="Keep up-to-date with new products, services, news and special offers." size="20" name="email" id="email" class="off field required email"> 
       <input type="image" src="/content/images/contact-arrow.png" name="intouch-submit" class="imgbtn"> 
       </div> 
      </form> 

在我的网页,我包括以下几个JS文件:

在我脚本文件我这样做:

// contact form. 
$('#stay-in-touch').validate({ 
    submitHandler: function (form) { 
     $(form).ajaxSubmit({ 
      success: function (response, status, xhr, form) { 
       $('#stay-in-touch div').fadeOut('slow', function() { 
        $('#stay-in-touch').append('<div class="msg">' + response.msg + '</div>'); 
       }); 
      } 
     }); 
     return false; 
    } 
}); 

但submitHandler不会触发。

任何想法?

我试着在submitHandler里放置一个ALERT(..),但没有喜悦。映射验证的代码肯定正在运行。

你可以看到现场代码在这里:

http://www.energyjump.co.uk/

+2

.ajaxsubmit()是一种形式的插件..有你还说,你的HTML – 2011-06-02 11:22:18

回答

1

我认为你需要一个<input type="submit",不只是一个普通的按钮/图像。

+0

不necassarily如果他使用jQuery表格插件.. – 2011-06-02 11:31:47

1

其工作。当您输入正确的电子邮件时,请点击显示警报的链接。

submitHandler只有在确认无误后才能使用。请检查一下。

如果你想显示错误信息或东西尽量做到在高光或unhighlight性质