Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
rated 0 times [  86] [ 4]  / answers: 1 / hits: 43512  / 14 Years ago, tue, january 25, 2011, 12:00:00

I want to have a password field which says Password in it before a user enters their password (so they know what the field is)

I'd rather just use Javascript, importing jQuery for this alone seems wasteful, but I have no idea how to. The images explain quite clearly:

What it looks like:


What I want it to look like:


It's only a very simple website and the most basic of logins (has no validation etc)

Any ideas?

<input id=username name=username class=input_text type=text value=Username  />
<input id=password name=password class=input_text type=password value=Password />

More From » html


Change your password input to be a simple input type text. Then, with JavaScript (or JQuery) on focus event, change it to be a input type password.

Here is a little untested sample with plain JavaScript (no JQUERY):

<script type=text/javascript>
function makeItPassword()
.innerHTML = <input id=password name=password type=password/>;
<span id=passcontainer>
<input onfocus=return makeItPassword() name=password type=text value=Type Password />

[#94058] Monday, January 24, 2011, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.

Total Points: 730
Total Questions: 99
Total Answers: 99

Location: South Georgia
Member since Fri, Nov 13, 2020
4 Years ago