jQuery submit | How to use form submit method of jQuery with example

jQuery submit method

As web developer one needs to use HTML forms in many scenarios, to collect user information for different purposes.

As a user clicks on Submit button, a Submit event occurs. jQuery provided submit() method to handle submit event where a function can be attached to perform certain actions e.g. checking form fields before submitting to the database.

This chapter guides through the syntax of the submit() method of jQuery and its usage by an example.

Syntax of using the submit method

This is how you may use the submit jQuery method:


Using submit method with function


As this method works only with forms’ elements, so selector = form or form’s elements where you need to handle the submit event.

Example of using submit() method

After opening the demo page, enter the test information in the form fields and press the “submit now” button. The submit event will occur where the submit method is used to trigger an alert:

jQuery submit

Experience this example online

Example of Submit() to prevent submit if First name field is empty

Experience this example online

Read more: jQuery preventdefault

Was this article helpful?

Related Articles

Leave A Comment?