In this article I will explain with an example, how to perform Password and Confirm Password validation for Password TextBox using jQuery in ASP.Net Core MVC.
The values of the Password and Confirm Password TextBoxes are compared using jQuery and if the values do not match an error message is displayed.
The Controller consists of following Action method.
Action method for handling GET operation
Inside this Action method, simply View is returned.
public class HomeController : Controller
    public IActionResult Index()
        return View();
The View consists of two HTML Password TextBoxes and a Button.
Inside the document ready event handler, the Button has been assigned a jQuery Click event handler.
When the Submit Button is clicked, the values of the Password and the Confirm Password TextBoxes are fetched and are compared.
If the values do not match, an error message is displayed using JavaScript Alert Message Box.
    Layout = null;
<!DOCTYPE html>
    <meta name="viewport" content="width=device-width" />
            <td><input type="password" id="txtPassword" /></td>
            <td>Confirm Password:</td>
            <td><input type="password" id="txtConfirmPassword" /></td>
            <td><input type="button" id="btnSubmit" value="Submit" /></td>
    <script type="text/javascript" src=""></script>
    <script type="text/javascript">
        $(function () {
            $("#btnSubmit").click(function () {
                var password = $("#txtPassword").val();
                var confirmPassword = $("#txtConfirmPassword").val();
                if (password != confirmPassword) {
                    alert("Passwords do not match.");
                    return false;
                return true;
ASP.Net Core MVC: Password and Confirm Password validation using jQuery
Browser Compatibility

The above code has been tested in the following browsers.

Internet Explorer  FireFox  Chrome  Safari  Opera 

* All browser logos displayed above are property of their respective owners.