Code Snippet: Show/Hide password on checkbox select while login or registration.

  1. HTML5 and 2. jQuery
<!-- HTML5 form input -->

<input type="password" name="password" id="upassword" />
<input type="checkbox" id="show-password">Show Password

<!-- jQuery function for toggle show/hide type for password input -->

<script>
    $(document).ready(function() {
        $("#show-password").change(function(){
            $(this).prop("checked") ?  $("#upassword").prop("type", "text") : $("#upassword").prop("type", "password");    
        });
    });
</script>

Leave a Reply

Related Posts