1

I'm using JQuery validate plug in and getting too much recursion error and have no idea why.

Here's a fiddle to show the error (you can see it in firebug)

To test: enter "john@hotmailcom" in first field, then tab out and see error msg, then click back in and change it to "[email protected]" and tab out again

Here the JQ:

  // ensure password contains at least one number and one letter    
  $.validator.addMethod("passwordRegex", function(value, element) {
    return this.optional(element) || /[a-z].*[0-9]|[0-9].*[a-z]/i.test(value);
  }, "Password must contain letters & numbers");

  $("#groupReg").validate({
    errorElement: 'span',
    errorClass: 'field-validation-error2',
        rules: {
            Email: {
                required: true,
                email: true
            },
            EmailConfirm: {
                required: true,
                email: true,
                equalTo: Email
            },
            Password: {
                required: true,
                minlength: 6,
                passwordRegex: "Password format not valid"
            },
        },
        messages: {
            Email: {
                required: "to continue, please enter your email address",
                email: "that's not a valid email address"
      },
            EmailConfirm: {
                required: "to continue, please enter your email address again",
                email: "that's not a valid email address",
                equalTo: "Please ensure the email addresses match"
            },
            Password: {
                required: "to continue, please enter a password using letters and numbers",
                minlength: "Your password must be at least 6 characters long"
            }
        },
    success: function() {           
      $( "#groupReg" ).submit();
    },
    });

Any idea what's wrong?

1
  • 2
    Validate event triggered from submit event would be typical. Why are you submitting from the success? Commented Jan 26, 2015 at 14:14

1 Answer 1

2

Remove the call to submit() from the success handler - and possibly the entire success handler if that is all you were using it for.

That handler is used when a field is made valid, calling it as you are is ending up in an infinite loop.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.