开发者

jQuery Validate not firing submitHandler

开发者 https://www.devze.com 2023-03-10 09:20 出处:网络
I have a simple FORM: <form method=\"post\" action=\"/home/keepintouch\" id=\"stay-in-touch\"> <div>

I have a simple FORM:

<form method="post" action="/home/keepintouch" id="stay-in-touch">
              <div>
                <开发者_JS百科;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>

In my page I'm including the following JS files:

And in my script file I do this:

// 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;
    }
});

But the submitHandler doesn't fire.

Any ideas?

I've tried placing an ALERT(..) inside the submitHandler but no joy. The code to map validation is definitely running.

You can see the live code here:

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


I believe that you need an <input type="submit" , not just a regular button/ image.


its working . when you enter correct email click on the link it displaying the alert.

The submitHandler works only after validations are ok. Please check it.

If you want to show error message or something try to do it in highlight or unhighlight properties

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号