0

再会 !

我正在优化使用。但它的一般问题。

我有表单验证码,

$("#frmForm").validate({
    // Specify validation rules
    rules: {
      // The key name on the left side is the name attribute
      // of an input field. Validation rules are defined
      // on the right side
      email: {
        required: true,
        // Specify that email should be validated
        // by the built-in "email" rule
        email: true
      },
      password: {
        required: true,
        minlength: 5
      }
    },
    // Specify validation error messages
    messages: {

      password: {
        required: "Please provide a password",
        minlength: "Your password must be at least 5 characters long"
      },
      email: "Please enter a valid email address"
    },
    // Make sure the form is submitted to the destination defined
    // in the "action" attribute of the form when valid
    submitHandler: function(form) {

      form.submit();
    }
  });

我想写一些代码

$(window).trigger('theyClickedSubmit');

表单提交成功后。

请记住,我无法访问上面编写的 jquery 代码。我只是想在外面做。

我们可以这样做吗?

提前致谢。

4

1 回答 1

0

我想写一些代码$(window).trigger('theyClickedSubmit')

你会像这样用jQuery“捕获” a click...

$('#myButtonID').on('click', function() {
    alert('button was clicked');
});

表单提交成功后。

除非它是通过 ajax 提交的并且您可以访问该 ajax 代码,否则您将无权知道它已提交。

请记住,我无法访问上面编写的 jquery 代码。我只是想在外面做。

我们不知道这意味着什么,您的问题也完全不清楚。你究竟需要捕捉什么?您在表单被验证之后但在提交之前form.submit()将在上面放置的任何代码submitHandler都会触发。为什么你不能访问这个 jQuery 代码?

如果您无法访问代码,那么您在此处无能为力,尤其是当该代码位于其他页面时。

于 2017-01-20T15:57:41.967 回答