How to show and hide password in html javascript | How To Toggle Password Visibility

How to show and hide password in html javascript

 <div class="form-group row">
                                <div class="col-12">
                                    <label>Password</label>
                                    <input class="form-control" type="password" required="" placeholder="Password" value="" name="password" id="password" >
                                    <input type="checkbox" onclick="myFun()">Show Password
                                </div>
                            </div>

 

<script>
    function myFun() {
        var x = document.getElementById("password");
        if (x.type === "password") {
            x.type = "text";
        } else {
            x.type = "password";
        }
    }
</script>

 

 

2021-10-03