Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2008-09-30
3
Medium Priority
?
201 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Thoughout my experience working on eCommerce web applications I have seen applications succumbing to increased user demand and throughput. With increased loads the response times started to spike, which leads to user frustration and lost sales. I ha…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Suggested Courses

618 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