I have a couple of elements, I would hardly call it a form, so I would rather they would not be wrapped inside the form element.
If the elements are not in the form tag, this is not a valid HTML document, so the behavior in the script may become unstable depending on how the browser works with garbled HTML.
Most browsers will create the form implicitly, but now you have no control over the behavior of the form. Typically, the default values ββare a form of message aimed at the requested page URL.
The problem is that you probably don't know which selector to use in jQuery to get a link to the form ... but I suppose $("form") will do the trick.
confirm when submit button is pressed but not cancel button
The plugin intercepts and fires the form submit event. Usually cancel buttons are html input elements with a type attribute set to "reset":
<input type="reset" value="cancel" />
Button
A reset will not cause the form to be submitted, and it will not result in validation.
If you use a different type of button, make sure onclick even returns false. This cancels the form submit action, but still allows you to run javasctipt yourself when the button is clicked.
Stephen M. Redd
source share