Jquery form submit and too much recursion

Share this post:

I just run into an issue where the form was submitted with Firefox (despite an error), but the page stopped loading under Google Chrome. With the help of FireBug I saw that there was a Javascript error with the message “too many recursions”.

This is the code that I had which caused too much recursion:

$("#formsignup").validate({
	submitHandler: function(form) {
	// Submit
	$('#formsignup').submit();
}, ...

According to a FAQ buried on the plugin page of Jquery I found that (quote); This results in a too-much-recursion error: $(form).submit() triggers another round of validation, resulting in another call to submitHandler, and voila, recursion. Replace that with form.submit(), which triggers the native submit event instead and not the validation.

Low and behold, I changed my code to the following and it works.

$("#formsignup").validate({
	submitHandler: function(form) {
	// Submit
	form.submit();
}, ...

Hope this helps someone else out there.

Over 10 years in business.

Self-funded. No investors. No bullshit.

More than 3,000 customers worldwide.

Helpmonks - no bullshit customer engagement service

Growth starts with action

Empower your team and delight your customers.

Helpmonks - email management for small businesses