Скрыть/показать пароль в inpute

<!-- Password field -->
Password: <input type="password" value="" id="password">

<!-- An element to toggle between password visibility -->
<input type="checkbox" onclick="showPass()">Show Password

    function showPass() {
        var x = document.getElementById("password");
        if (x.type === "password") {
            x.type = "text";
        } else {
            x.type = "password";
        }
    }