Welcome!

And don't forget to edit your signature & profile.

 

Icon

Statistics

  • Total posts 27015
  • Total topics 4909
  • Total members 6646
  • Our newest member
    trickell

TOP POSTERS

Styling Input Field w/ JavaScript onfocus & onblur

All problems related to JavaScript and AJAX are discussed and resolved here.
   
I have used the following JavaScript so that when I click on the particular input field (focus), it removes the field's content values, i.e. the input box for users to enter their email says "Email" and when the users clicks on this input field the "Email" text gets removed. Basic stuff here. Facebook is a good example of this functionality. I would like to incorporate another feature that I currently do not have and that Facebook does have. I consider it a good design decision.

For the password field specifically, the "type" is set to "password" so it produces the *****. However, I would like the password field to say "Password" when it is not in focus. Then when the user goes to enter their password it gets starred out. Again, Facebook is a good example of what I am talking about.

Email:

<input class="input" type="text" onfocus="if(this.value=='Email') this.value='';" onblur="if(this.value=='') this.value='Email';" value="Email" />

Password:

<input class="input" type="password" onfocus="if(this.value=='Password') this.value='';" onblur="if(this.value=='') this.value='Password';" value="Password" />


Please advise me on how I can incorporate this feature for the password field. Regards.
Eraser35
Smashing <hr />
 
Posts: 53
Joined: Sun May 31, 2009 12:04 am
   

Return to JavaScript & AJAX



Who is online

Users browsing this forum: No registered users and 1 guest