views:

725

answers:

4

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?

+4  A: 

With pure JS you can do:

this.form.submit();
fmsf
A: 

fmsf's answer is good if you want to use code to do this but if the user clicks a submit button that has validation code attached to it it will submit as long as you don't suppress the event or return false.

So you can simply use a submit button instead of a regular one and get the same result

Sruly
+4  A: 

Assuming your form had an id of "myform" the following jquery would cause it to be submitted.

$("#myform").submit();
JohnRudolfLewis
A: 

I am assuming that you want to use jQuery to submit a form back to ASP.NET.

There is a $.post(url, { param1: param1value, param2: param2value}, function(response){ // handle response }); syntax in jQuery which allows you to asynchronously submit a form to a code behind file.

The major conceptual change is that your page is not going to refresh and also your response should only contain what you want.

To understand in detail with a sample application please feel free to go through the following link:

http://sites.google.com/site/spyderhoodcommunity/tech-stuff/howtosubmitaformusingjqueryviaajaxtoanaspnetandreceivetheresponse

Kartik Sehgal