Show or Hide Toggle Password Input Field with Example

Posted by


Are you tired of the same old boring password input fields? Do you want to add some excitement and interactivity to your web forms? Look no further! In this article, we will explore how to use Bootstrap to create a show/hide toggle for password input fields. So sit back, relax, and get ready to level up your form design game!

Why Show/Hide Toggle?

Before we dive into the implementation details, let’s take a moment to understand why a show/hide toggle for password input fields is a great idea.

  1. Enhanced User Experience: By allowing users to toggle the visibility of their password, you empower them with control over their own data. This can greatly improve user experience and satisfaction.
  2. Improved Security: While it may seem counterintuitive, a show/hide toggle can actually enhance security. Users are more likely to choose strong passwords if they can see them while typing. Additionally, it prevents shoulder surfing attacks, where someone could potentially see the user’s password over their shoulder.
  3. Sleek and Modern Design: Adding a show/hide toggle to your password input fields gives your forms a modern and stylish look. It adds that extra touch of interactivity that users love.

Step : Include Bootstrap

First, make sure you have included the Bootstrap CSS and JavaScript files in your HTML document. You can either download the files and host them locally or use a CDN.

<!DOCTYPE html>
	<title>Bootstrap Hide Show Password</title>
	<link rel="stylesheet" type="text/css" href="">
	<script type="text/javascript" src=""></script>
	<script type="text/javascript" src=""></script>
	<script type="text/javascript" src=""></script>

<div class="container">
		<div class="form-group">
			<input type="text" name="username" class="form-control">
		<div class="form-group">
			<input type="password" id="password" name="password" class="form-control" data-toggle="password">
		<div class="form-group">
			<button class="btn btn-success">Submit</button>

<script type="text/javascript">


Output 1:- With hide password

Output 2:- With show password

It will help you …!!!

Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x