shinichi♥stranger
carol♥z-motion
aquila♥(inky);paper
map♥swordmanspirit

CSS tutorials: Delete form-value with onlick

Level:
Forms are something you provide visitors to leave you a message or something. Actually it's not that diffecult to fill out forms but sometimes people just miss areas. For this reason I do write some default text in some fields to make it more clear.
Sadly to some people it's irritating if they have to delete the default text or not. For this reason I make use of an onclick-funtion to delete previous written default text with only one click.


1. Add onlick-funtion to your input

This is so damn easy I don't even have to write anything about it. Just have a look at your input textfield which needs to look simlar to this one:
<input name="sample" type="text" value="I'm a default text. Click me!" />
If you replace the code above with the one below you'll add the delete-funtion which puts back the predefined value from default text to zero.
<input name="sample" type="text" value="I'm a default text. Click me!" onclick="if(this.value && this.value==this.defaultValue)this.value=''" />
A very short tutorial but I guess no further explanations are needed. But if it appears you want me to explain more parts of this code drop me a line :D
last updated on February 5, 2010
⬅ GO BACK

general

style selection

broad your mind

creative aids