Clear Textboxes When Clicked


If you have a form on your website with a textbox, this code is for you. Find the textbox in your code, and add this inside the tag:
HTML Code
  1. onclick="this.value=''"

When people click the textbox to type in information, the box will clear.

Here is an example of what your code should look like:
HTML Code
  1. <input type="text" name="textbox" value="testing" onclick="this.value=''" />
Naresh's Avatar
Author:
Views:
2,405
Rating:
Posted on Monday 9th June 2008 at 04:53 AM
Adam981
Adam981's Avatar
is there anyway to have it clear if someone also tabs to the password field?
Posted on Friday 6th June 2008 at 06:44 PM
ashwill
ashwill's Avatar
Fantastic, I've been looking for something like this. Thanks.. :)
Posted on Friday 6th June 2008 at 03:48 PM
Adam981
Adam981's Avatar
LOL! nevermind my mistake :(
Posted on Friday 6th June 2008 at 03:47 PM
Adam981
Adam981's Avatar
wow, that just doesnt work for me...

<input type='text' value='Name' onclick='this.value='' name='username' size='10' maxlength='25'>
Posted on Tuesday 11th March 2008 at 07:48 PM
cyruswu
cyruswu's Avatar
This is a very ok way of explaining. He probably didn't even used it in his unsecured user system.
Posted on Saturday 21st July 2007 at 04:56 PM
ilyas-shezad
ilyas-shezad's Avatar
fth8er u make it too complicated :@ :P
its alryt u can use onclick="this.value=''"
Noticed that i used ' ' instead of speech marks
Posted on Monday 7th May 2007 at 07:29 PM
Diablosblizz
Diablosblizz's Avatar
Maybe you should post your user system. I had a tutorial for the Naresh system and I got stuck.

It may be helpful for some.
Posted on Monday 7th May 2007 at 03:11 PM
FtH8er
FtH8er's Avatar
P.S. I have Found That Something Like This:

Code
<input type="password" size="15" maxlength="25" name="password" class="forminputb" onclick="if (this.value == 'Password') { this.value = ''; }" onfocus="if (this.value == 'Password') { this.value = ''; }" onblur="if (this.value == '') { this.value = 'Password'; }" type="password" value="Password" />

Works Alittle Better. Scicne It Clears The Form And keeps the form cleared unless there is nothing in the text box. But Yours Works As Well.
Posted on Sunday 6th May 2007 at 05:40 PM
FtH8er
FtH8er's Avatar
Nice little script man. But for the people that are just beginning, the actual code should be:

onclick="this.value=''" (for my usersystem, which is naresh's or w.e.)

while you had this:

onclick="this.value='"

But you need to have '' after the value= so it tells it to put nothing in there. But all in all great job and nice tut.