password and confirm password validation in jquery Example

password and confirm password validation in jquery using keyup event to check whether password and confirm password is match or not.

password and confirm password validation in jquery

How to validate password and confirm password is match or not jQuery. The following HTML Markup consists of two HTML Password TextBoxes and a Button.

How To Validate Password And Confirm Password Using JQuery?

index.html

<html>
  <body>
      <head>
        <meta charset="utf-8">
        <title>How to validate password and confirm password in jquery - www.pakainfo.com</title>
        <link href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet">
        <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
        <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
      </head>
      <div class="row">
        <div class="col-md-6 col-md-offset-3">
          <h1>How to validate password and confirm password in jquery - www.pakainfo.com</h1><br />
            Enter Password <input type="password" class="form-control" id="SecPass" placeholder="Enter a password" name="secure-pass"><br /> <br / >
            Enter Confirm Password <input type="password" class="form-control" id="ConfirmSecPass" placeholder="Enter a Confirm Password" name="confsecure-pass" >
            <div style="margin-top: 7px;" id="CheckSecPassMatch"></div>
        </div>
      </div>
  <body>
</html>

Don’t Miss : Validate Email Password Using JQuery

Read Also:  Bootstrap 4 Carousel Slider With Thumbnails

main.js

<script>
$(document).ready(function () {
   $("#ConfirmSecPass").on('keyup', function(){
    var secure-pass = $("#SecPass").val();
    var confirmSecPass = $("#ConfirmSecPass").val();
    if (secure-pass != confirmSecPass)
        $("#CheckSecPassMatch").html("Password does not match !").css("color","red");
    else
        $("#CheckSecPassMatch").html("Password match !").css("color","green");
   });
});
</script>

I hope you get an idea about password and confirm password validation in jquery.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.