. . .

Create two text boxes and check passwords match

javascript
Please share the article
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  <!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">

<div class="container">

        <h3>Create two textbox & choose passwords match?</h3>

        <hr />

        <div class="form-group-row col-md-8 m-auto">
            <form class="form-signin" method="post">

                <h3 class="font-weight-bold text-dark">Check Passwords</h3>

                <input type="password" id="password" class="form-control flex-md-fill flex-sm-fill my-3 rounded-pill" placeholder="Password" value="" />

                <input type="password" id="verifypassword" class="form-control flex-md-fill flex-sm-fill my-3 rounded-pill" placeholder="Confirm Password" value="" />

                <button type="button" class="btn btn-outline-primary btn-lg btn-block flex-md-fill flex-sm-fill m-auto rounded-pill" onClick="checkPass()">Submit Me</button>
            </form>
        </div>

    </div>
function checkPass() {


        var password = document.getElementById('password').value.trim();

        var confirmpassword = document.getElementById('verifypassword').value.trim();

        if (password == "") {

            swal({
                title: "Faliure!",
                text: "password cannot be empty!",
                icon: "error",
                button: "ok",
            });

            return false;

        }

        if (password.length <= 7) {

            swal({
                title: "Faliure!",
                text: "Password must be eight character!",
                icon: "error",
                button: "ok",
            });

            return false;
        }


        if (confirmpassword == "") {

            swal({
                title: "Faliure!",
                text: " Confirm password cannot be empty!",
                icon: "error",
                button: "ok",
            });

            return false;

        }

        if (confirmpassword.length <= 7) {

            swal({
                title: "Faliure!",
                text: "Verification Password must be eight character!",
                icon: "error",
                button: "ok",
            });

            return false;
        }

        if (password != confirmpassword) {

            swal({
                title: "Faliure!",
                text: "password is not matching!",
                icon: "error",
                button: "ok",
            });

            return false;

        }

        if (password == confirmpassword) {

            swal({
                title: "Success!",
                text: "passwords matched",
                icon: "success",
                button: "OK",
            });

            return true;

        }

    }

Leave a Reply

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

nineteen − eight =