---
title: "How to display error messages using jQuery validation?"  
description: "How to display error messages using jQuery validation?"  
author: "Utpal Vishwas"  
published: 2023-05-11  
updated: 2023-05-11  
canonical: https://www.mindstick.com/forum/158286/how-to-display-error-messages-using-jquery-validation  
category: "jquery"  
tags: ["jquery", "jquery validate", "form validation", "html validation"]  
reading_time: 1 minute  

---

# How to display error messages using jQuery validation?

How to display [error](https://yourviews.mindstick.com/view/88527/fixing-quickbooks-error-4120-reinstalling-vs-repairing) [messages using jQuery validation](https://www.mindstick.com/forum/158287/how-to-customize-error-messages-using-jquery-validation)?

## Replies

### Reply by Aryan Kumar

You can display [error messages](https://www.mindstick.com/forum/160245/how-to-customize-error-messages-with-a-data-annotation-in-asp-dot-net-core) using [jQuery validation](https://www.mindstick.com/forum/158280/how-to-include-jquery-validation-in-a-web-page) by using the errorPlacement option. The errorPlacement option is a function that is called when an error is found in a form field. The function takes two arguments: the first argument is the element that contains the error message, and the second argument is the element that contains the form field. For example:

JavaScript

```plaintext
$(document).ready(function() {
  // Validate the form
  $("#myForm").validate({
    rules: {
      username: {
        required: true,
        maxlength: 20
      },
      password: {
        required: true,
        minlength: 6
      }
    },
    errorPlacement: function(error, element) {
      // Display the error message next to the form field
      error.insertAfter(element);
    }
  });
});
```

The errorPlacement function can be used to customize the way that error messages are displayed. For example, you can display the error messages above or below the form fields, or you can display them in a separate container.


---

Original Source: https://www.mindstick.com/forum/158286/how-to-display-error-messages-using-jquery-validation

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
