Development JQuery Web Technologies

Password Mismatch

you can use the following code to check the password matching

 $(document).ready(function () {
         
        $("#confirm_password").keyup(function () {
           var password = $("#newpass").val();
            var confirmPassword = $("#confirm_password").val();

            if (password != confirmPassword) {
                $("#divCheckPasswordMatch").html("Passwords do not match!");
                $("#divCheckPasswordMatch").removeClass("text-success");
                $("#divCheckPasswordMatch").addClass("text-danger");
            }
            else {
                $("#divCheckPasswordMatch").removeClass("text-danger");
                $("#divCheckPasswordMatch").addClass("text-success");
                $("#divCheckPasswordMatch").html("Passwords match.");
            }
        }
        );
        
    });
    $("form").submit(function (e) {
        if ($("#newpass").val() != $("#confirm_password").val()) {
            
            e.preventDefault();
            alert("Your passwords doesn't match.");
        }
    })

Leave a Reply

Your email address will not be published. Required fields are marked *