In this article I will explain with an example, how to validate HTML Form using jQuery Validation plugin in ASP.Net Core MVC.
This article makes use of jQuery ValidationEngine plugin for performing validation.
jQuery ValidationEngine plugin will perform validation for various Form fields like TextBox, DropDownList, etc. and the type of validations involved would be Required, Email, Password confirmation, Minimum and Maximum Length, Telephone number, Mobile Cell number, Date Format such as dd/MM/yyyy dates.
Download jQuery ValidationEngine Plugin
You can download the jQuery ValidationEngine plugin using the link below.
The Controller consists of following two Action methods.
Action method for handling GET operation
Inside this Action method, simply the View is returned.
Action method for handling POST operation
This Action method is executed when the Submit button is clicked.
Inside this Action Method, RedirectToAction method is called which redirects to the Index Action method.
public class HomeController : Controller
    public IActionResult Index()
        return View();
    public IActionResult Submit()
        return RedirectToAction("Index");
The View consists of a HTML Form which has been created with following ASP.Net Tag Helpers attributes.
asp-action – Name of the Action. In this case the name is Submit.
asp-controller – Name of the Controller. In this case the name is Home.
method – It specifies the Form Method i.e. GET or POST. In this case it will be set to POST.
The Form consists of some INPUT TextBoxes, a HTML DropDownList and a Submit button.
The TextBoxes and DropDownList to be validated have been set with the class property. This particular class will be used by jQuery ValidationEngine plugin for validation.
Basic Required Validation
For Required validation, the class property is set as validate[required] for the TextBox or DropDownList controls.
Note: For the DropDownList control it is necessary that the value for the first or default item is set to blank.
Email Address Validation
For validating a TextBox that will accept email address as input, the class property is set as validate[required,custom[email]].
This ensures that the TextBox will contains data and then perform email address validation.
Confirm Password Validation
In order to validate Confirm Password, the class property is set as validate[required,equals[txtPassword]].
The validation makes sure that the second TextBox must contain value and the value must be equal to the TextBox whose ID has been specified along with the equals class.
Integer, Numbers (Numeric), Minimum Length, Maximum Length and Phone Validation
jQuery ValidationEngine plugin also provides validation for numbers i.e. numeric data and also the data length must have some minimum and maximum characters.
In order to validate this, the custom, maxSize and minSize need to be specified.
Date Format Validation (dd/MM/yyyy)
jQuery ValidationEngine plugin validates ISO Date format i.e. yyyy-mm-dd.
In order to validate Date with dd/MM/yyyy format, this plugin has provision to add custom validation scripts.
Implementing the jQuery ValidationEngine Plugin
First, you need to inherit the jQuery library and jQuery ValidationEngine plugin Scripts and the CSS files on the View.
Then inside the jQuery document ready event handler, the jQuery ValidationEngine plugin is applied to the Form.
There is a JavaScript function DateFormat which validates Date with dd/MM/yyyy format and it accepts 4 parameters field, rules, i and options.
Finally, a string message is returned from the DateFormat JavaScript function when validation fails.
@addTagHelper*, Microsoft.AspNetCore.Mvc.TagHelpers
    Layout = null;
<!DOCTYPE html>
    <meta name="viewport" content="width=device-width" />
    <style type="text/css">
        body { font-family: Arial; font-size: 10pt; }
        input, select { width: 150px; }
    <form method="post" asp-controller="Home" asp-action="Submit" id="form1">
        <table border="0" cellpadding="0" cellspacing="0">
                <td>Please fill the following Form</td>
            <tr><td style="height: 40px"></td></tr>
                <td><input type="text" id="txtName" class="validate[required]" /></td>
            <tr><td style="height: 40px"></td></tr>
                <td><input type="text" id="txtEmail" class="validate[required,custom[email]]" /></td>
            <tr><td style="height: 40px"></td></tr>
                    <select id="ddlCities" class="validate[required]">
                        <option value="">Please Select</option>
                        <option value="1">Mumbai</option>
                        <option value="2">Delhi</option>
                        <option value="3">Kolkatta</option>
                        <option value="4">Chennai</option>
            <tr><td style="height: 40px"></td></tr>
                <td><input type="password" id="txtPassword" class="validate[required]" /></td>
            <tr><td style="height: 40px"></td></tr>
                <td>Confirm Password:</td>
                <td><input type="password" id="txtConfirmPassword" class="validate[required,equals[txtPassword]]" /></td>
            <tr><td style="height: 40px"></td></tr>
                <td>Mobile Phone Number:</td>
                <td><input type="text" id="txtPhoneNumber" class="validate[required,custom[integer],maxSize[10],minSize[10]]" /></td>
            <tr><td style="height: 40px"></td></tr>
                <td>Birth Date (dd/MM/yyyy):</td>
                <td><input type="text" id="txtBirthDate" class="validate[required,funcCall[DateFormat[]]" /></td>
            <tr><td style="height: 40px"></td></tr>
                <td><input type="submit" value="Submit" /></td>
    <link rel="stylesheet" type="text/css" href="" />
    <script type="text/javascript" src=""></script>
    <script type="text/javascript" src=""></script>
    <script type="text/javascript" src=""></script>
    <script type="text/javascript">
        $(function () {
            $("#form1").validationEngine('attach', { promptPosition: "topRight" });
        function DateFormat(field, rules, i, options) {
            var regex = /^(0?[1-9]|[12][0-9]|3[01])[\/\-](0?[1-9]|1[012])[\/\-]\d{4}$/;
            if (!regex.test(field.val())) {
                return "Please enter date in dd/MM/yyyy format."
ASP.Net Core MVC: Validate Form using jQuery Validation Plugin