JQuery capture form submission

I have a number of conditions that I would like to check before submitting the form, so that I create:

$("Step2_UpdateCartForm").submit(function () { if (!procssingEmails) { return true; } else { return false; } 

And I have a number of events that can lead to the submission of the form, so I have something like:

 function fireUpdateCart() { if (isUpdateCartPending) { clearCartOptionDefaultValues(); $("#Step2_UpdateCartForm").submit(); } } 

in several different places. I expect the above statement to send processing to this first block of code, but a form is submitted instead.

I am mistaken in expecting my validation block to be processed

+7
jquery forms
source share
2 answers

You do not have the identifier "#" from the definition of your event. This is the probable cause of your problem. The first line should look like this:

 $("#Step2_UpdateCartForm").submit(function () { ^ 
+10
source share

Your selector is missing #. You should use the following:

 $("#Step2_UpdateCartForm").submit(function () { if (!procssingEmails) { return true; } else { return false; } 

And BTW, maybe your "procssingEmails" are spelled incorrectly, right?

+6
source share

All Articles