Here we are calling a validate() function before submitting a form data to the webserver. If validate() function returns true, the form will be submitted, otherwise it will not submit the data.
Most HTML forms have a submit button at the bottom of the form. Once all of the fields in the form have been filled in, the user clicks on the submit button to record the form data. The standard behaviour is to gather all of the data that were entered into the form and send it to another program to be processed.
A form without an action attribute is not a form, according to standards - and will actually cause a page reload in some browsers..
By default, the method attribute is set to “get”. This means that your form will send data over an HTTP GET request when it is submitted. You can change the method by specifying “method='post'” in your opening <form> tag. Data from a form is sent to the “action” URL when a submit button is clicked.
Try this:
jQuery("#form").submit(function(e) {
var self = this;
e.preventDefault();
jQuery.fancybox('<div class="box">Some amazing wonderful content</div>', {
'onClosed' : function() {
self.submit();
}
});
return false; //is superfluous, but I put it here as a fallback
});
javascript is asynchronous so you cannot delay the return statement.
UPDATE
To make it so that the code above works, change the name
of you submit button to something else, for example:
<input type="submit" name="submit_me" value="Submit" />
(response to Rick's question under Neal's answer: "any other way? Because I don't have direct access to this html")
If you, for some reason, need a submit button to have ID="submit" and cannot use form.submit method (because it links to "input[type=submit]#submit" button) you can do this:
$('<form>')[0].submit.call(form); //jQuery
//OR:
document.createElement('form').submit.call(form); //pure HTML w/o any framework
i.e. create new empty form and use its submit method to call it in scope of your own form
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With