I have an input text field, which has a value "something" by default, but when I start to type, I want that the default value changes color, and the text i'll type, another one.
How can i do that?
<input type="text" value="something" onclick="this.value=''" />
To keep it simple like your example:
<input type="text" value="something" onclick="this.value='';this.style.color='red';" />
And that should pretty much do it.
You may want to try the following:
<input type="text" value="something"
onFocus="if (this.value == 'something') this.style.color = '#ccc';"
onKeyDown="if (this.value == 'something') {
this.value = ''; this.style.color = '#000'; }">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With