Today, when doing exercises, use jquery to do the wrong thing at the front desk.
There is a need to prevent users from submitting a form when checking for logic that has errors. Such a demand.
At that time, because do not want to use
<input type= ' Submit ' onsubmit= "return XX ()"/>
This method, so direct code out of such a sentence.
$ ("#提交按钮"). Submit (function () {return false;})
Then, when testing, you can actually implement a block form submission when the user enters the wrong information.
But the problem comes with it. After the user corrects the error. When submitting again, the form is no longer submitted.
In other words, just as with the previous error message, there will be no response from the user point submission.
Later, the internet looked up. Presumably, because when you run that sentence, the browser stops the default event and event bubbling for the specified object.
So, as long as you run that sentence, no matter how you click on that button, the form will not be submitted.
At this point, know the reason, began to solve. However, at this time again fell into another cul-de-sac, then kept thinking, how to make the submit button to restore the initial state. Wasted a lot of time.
In fact, just to make sure that all the logic is correct, call the
$ ("#表单ID"). Submit ()
It's okay.