Posted By

luman on 10/23/06


Tagged

input


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

matt
m0rris


input default value


 / Published in: JavaScript
 

URL: http://discoapp.com/beta/

  1. <input id="1" name="post[email]" value="E-mail Address" style="width:100%; text-align: center; color: grey; margin-bottom: 10px;" onblur="if (this.value == '') {this.value = 'E-mail Address'; document.getElementById(1).style.color = 'grey';}" onfocus="if (this.value == 'E-mail Address') {this.value = ''; document.getElementById(1).style.color = '#000000'; }" />

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: Rohit on December 5, 2008

There's big hole in your code men , when you load it first time it show the gray color 'E-mail Address' but when you just click on textbox and don't put any text in it , the textbox rewrites itself with 'E-mail Address' but text color is black and not gray which it should be. Hopefully you understand what i say. Well plz reply if you find a way out of that error.

Posted By: lesha on February 26, 2009

Rohit, just change document.getElementById(1) into this:

Posted By: lesha on February 26, 2009

`

`

Posted By: lesha on February 26, 2009

<input id="1" name="post[email]" value="E-mail Address" style="width:100%; text-align: center; color: grey; margin-bottom: 10px;" onblur="if (this.value == '') {this.value = 'E-mail Address'; this.style.color = 'grey';}" onfocus="if (this.value == 'E-mail Address') {this.value = ''; this.style.color = '#000000'; }" />

You need to login to post a comment.