Solved

I would like to add a display characters option to password entries

Posted on 2008-09-30
3
192 Views
Last Modified: 2010-04-16
Some windows password input boxes have a checkbox that allows you to see the characters you are entering into a password input.
It seems a pretty easy answer with javascript checkbox deciding whether to input in password style or text style.. but I am pretty weak at javascript
0
Comment
Question by:levelninesports
  • 2
3 Comments
 
LVL 4

Expert Comment

by:TurboBorland
ID: 22611509
You would have to use something that can change a value in the form.  Something like DOM manipulation in Javascript.
Simply change the type= from "password" to "text" when the checkbox is checked.
<html>
<script language="javascript">
function show() {
document.formname.pass.type = 'text';
}
</script>
<body>
<form name="formname" method="POST" action="">
Username:  <input type="text" value="" name="user" /><br />
Password:  <input type="password" value="" name="pass" /><br />
<input type="checkbox" name="change" onClick="show()" />Show Password<br />
<input type="submit" value="Submit" />
</form>
</body>
</html>
0
 

Author Comment

by:levelninesports
ID: 22621122
That's pretty good.. now what do I have to do to have the input type switch back to password when they unclick?
0
 
LVL 4

Accepted Solution

by:
TurboBorland earned 500 total points
ID: 22621681
Add an if/else statement:
<html>
<script language="javascript">
function show() {
  if (document.formname.change.checked == true) {
    document.formname.pass.type = 'text';
  } else {
    document.formname.pass.type= 'password';
  }
}
</script>
<body>
<form name="formname" method="POST" action="">
Username:  <input type="text" value="" name="user" /><br />
Password:  <input type="password" value="" name="pass" /><br />
<input type="checkbox" name="change" onClick="show()" />Show Password<br />
<input type="submit" value="Submit" />
</form>
</body>
</html>
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

      Install BugTracker on Windows 2008 server Step 1:  Install windows 2008 server 32 bit OS and configure IIS. Step 2:  Install SQL server ( SQL server 2005 or SQL server 2005 Express edition. The installer for 2008  version isn’t very f…
Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now