jQuery Api Submit() Event By Example

Here learn form event by example. The jquery form submit event occurs when a form is submitted. Jquery form submit event can only be used on elements.

jQuery submit()

When the user submit the form, then the submit event is sent to the element. This event can only be used on elements.

This event can only be used on elements. The submit () method triggers the submit event, or appends the function to run when the submitted event occurs.



It triggers the submit event for selected elements.


Parameters of submit() event




It is an optional parameter. It is used to specify the function to run when the submit event is executed.

Example of jQuery submit()

Let’s see an example with demonstrate jQuery submit().

<!DOCTYPE html>  
<html lang="en">  
  <meta charset="utf-8">  
  <title>Submit Form demo</title>  
  p {  
    margin: 0;  
    color: blue;  
  div,p {  
    margin-left: 10px;  
  span {  
    color: red;  
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<p>Type 'test' to submit this form finally.</p>  
<form action="javascript:alert( 'success!' );">  
    <input type="text">  
    <input type="submit">  
$( "form" ).submit(function( event ) {  
  if ( $( "input:first" ).val() === "javatpoint" ) {  
    $( "span" ).text( "Submitted Successfully." ).show();  
  $( "span" ).text( "Not valid!" ).show().fadeOut( 2000 );  
Spread the love

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *