---
title: "How to submit a form using jQuery validation after successful validation?"  
description: "How to submit a form using jQuery validation after successful validation?"  
author: "Utpal Vishwas"  
published: 2023-05-11  
updated: 2023-05-11  
canonical: https://www.mindstick.com/forum/158288/how-to-submit-a-form-using-jquery-validation-after-successful-validation  
category: "jquery"  
tags: ["jquery", "jquery validate", "html form", "form validation"]  
reading_time: 2 minutes  

---

# How to submit a form using jQuery validation after successful validation?

How to submit a [form using jQuery](https://www.mindstick.com/forum/156660/reset-any-form-using-jquery) [validation](https://www.mindstick.com/articles/12234/validation-using-data-annotation-using-entity-framework) after successful validation?

## Replies

### Reply by Aryan Kumar

Sure. Here are the steps on how to submit a [form](https://www.mindstick.com/forum/6/multi-form-mfc-application) using [jQuery validation](https://www.mindstick.com/forum/158280/how-to-include-jquery-validation-in-a-web-page) after successful validation:

- First, you need to add the jQuery validation plugin to your website. You can do this by adding the following script tag to the head of your HTML document:

HTML

```plaintext
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.0/jquery.validate.min.js"></script>
```

- Next, you need to create a form and add the `id` attribute to it. The `id` attribute is used to identify the form so that the jQuery validation plugin can work with it. For example:

HTML

```plaintext
<form id="myForm">
  <input type="text" name="username">
  <input type="password" name="password">
  <input type="submit" value="Submit">
</form>
```

- Once you have created the form, you need to add the jQuery validation code to it. The jQuery validation code is used to validate the form fields and prevent the form from being submitted if any of the fields are invalid. For example:

JavaScript

```plaintext
$(document).ready(function() {
  // Validate the form
  $("#myForm").validate({
    rules: {
      username: {
        required: true,
        maxlength: 20
      },
      password: {
        required: true,
        minlength: 6
      }
    }
  });
});
```

- Finally, you need to add the code to submit the form when it is valid. The code below will submit the form when all of the fields are valid:

JavaScript

```plaintext
$(document).ready(function() {
  // Submit the form when it is valid
  $("#myForm").submit(function() {
    if ($(this).valid()) {
      // The form is valid, so submit it
      $(this).submit();
    }
    return false;
  });
});
```


---

Original Source: https://www.mindstick.com/forum/158288/how-to-submit-a-form-using-jquery-validation-after-successful-validation

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
