jQuery > Events

Catch Submit event in jQuery

How to catch the Submit event of the html Form element in jQuery?

To catch the submit event of the html form element, submit() method can be used.

        $("form").submit(function () {
            $("#divSubmit").fadeIn("fast").text("You have tried to submit the form")
            return false;

Above code attaches the submit event to the form element and when the form is submitted, it writes “You have tried to submit the form” with fadeout effect (we will learn about fadeout effect in following posts). But note that as the last statement of this function is “return false”, so the form is not be submitted. To submit the form, we must write “return true” in the last.

 Views: 9268 | Post Order: 85

Write for us

Hosting Recommendations