Minifycode 2021-10-03 Viewed 1.4K times HTML

In this article, you will learn 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>

 

 

How to show and hide password in html javascript, How To Toggle Password Visibility
minify code