• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 967
  • Last Modified:

onFocus event in password input field

his code on my login page:

<input type="text" name="id" value="Your Email Address or Account ID" onFocus="if(this.value=='Your Email Address or Account ID')this.value='';">

<input type="text" name="pw" value="Your Password" onFocus="if(this.value=='Your Password')this.value='';">

I need to use input type=text for the password field so that "Your Password" appears as the value. If I change the type to type=password, then by default the text displayed in the input field is *********************

Is there some way to display "Your Password" in the password field, but when the user starts typing his password, it appears as ********** ?

1 Solution
Try this:
<input type="text" name="pw" value="Your Password" onFocus="if(this.value=='Your Password'){this.value='';this.type='password';}">

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now