I've a form on my ASP.NET web page. There is submit button also. I've some validation logic attached to client-side click event of a button. I'd like to submit this form from my jQuery validation logic, how to achieve this?
Forms can be submitted either by clicking an explicit <input type="submit"> , <input type="image"> , or <button type="submit"> , or by pressing Enter when certain form elements have focus.
Submit a Form Using JavaScript The most simple way to submit a form without the submit button is to trigger the submit event of a form using JavaScript. In the below example we are going to create a function to submit a form. We will set that function at onclick event of a div tag.
$("#something-%"). submit(function(e) { e. preventDefault(); $("#some-span"). html(data); });
The NUMBER ONE error is having ANYTHING with the reserved word submit as ID or NAME in your form. If you plan to call . submit() on the form AND the form has submit as id or name on any form element, then you need to rename that form element, since the form's submit method/handler is shadowed by the name/id attribute.
Assuming your form had an id of "myform" the following jquery would cause it to be submitted.
$("#myform").submit();
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