Jquery验证插件停止表单提交

时间:2015-11-22 00:34:32

标签: javascript jquery forms jquery-validate

我尝试通过post提交数据并将其返回,但是即使我有一个submitHandler函数,我的jquery validate插件也在提交表单。

我使用jquery和jquery表单验证插件。

任何想法为什么?

$( "#signupForm" ).validate({
  rules: {
    email: {
        required: true,
        email: true
    },
    password: {
        required: true
    },
    password_again: {
      required: true,
      equalTo: "#password"
    },
    month: {
        required: true
    },
    day: {
        required: true
    },
    year: {
        required: true
    },
    gender: {
        required: true
    }
  },
  submitHandler: function(form) {
    alert('boom');
    $('form').find(":submit").attr("disabled", true).attr("value","Submitting...");
    $.post("includes/signup.php", {
        email: $('#email').val,
        password: $('#password').val,
        month: $('#month').val,
        day: $('#day').val,
        year: $('#year').val,
        gender: $('#gender').val,
        city: $('#city').val
    })
    .success(function(data) {
        console.log(data);
    });
    return false;
  }
});

0 个答案:

没有答案