This site is under maintenance. Some links may stop working, I will try to fix them ASAP. Sorry!
See my DrawingsRead my MumblingsCheck my WallpapersView my web.designsTake a look at my GraphicsLearn with my Tutorials

Here is HomeNews in PortugueseVisit my Links

drawings : renewal


Lombergar.com
pixel.colos
deviantART
ghostbone
Vincent Low
niklasp.com
Alfdesign
Jams Arts
Joylee.net
phirebrush


Want to link us?

Tutorial type : DHTML/JAVASCRIPT
Views : 4379

Clear textbox on click
Imagine you have a textbox like the following and you want it to clear when you click in it:



One easy way to accomplish that is by adding this attribute:

<input type="text" value="Textbox" onClick=" value=' '; ">

You'll notice though, that if you write something in the textbox and then click in it for some reason, it will clear it again, which isn't nice at all, as all content will be lost.
Of course, you can easily solve that, you just need to use some logic, with an "if", like this:

<input type="text" value="Textbox" onClick=" if(value=='Textbox') value=' '; ">

Where you should replace "Textbox" by whatever is the default value you want the textbox to have.
Here's a working example:



As you can see, it only clears when the word "Textbox" is in it, otherwise, it does nothing.


5946 days online | hosted by TSOhost (recommended!)
copyright © 2002 - 2018  | Share the links, not the content

Aqui fica uma compilação de todos os MP3's encontrados desse grande sócio, o caríssimo . . . Zé Dread. Ze Dread - Compilacao.zip (mp3's - 11,35 MB) || Ze Dread - Compilacao.nfo (informações) Saca lá essa cena... Para quem usa eMule, aqui ficam os ed2k links: Ze Dread - Compilacao.zip || Ze Dread - Compilacao.nfo Aqui fica uma compilação de todos os MP3's encontrados desse grande sócio, o caríssimo . . . Zé Dread. Ze Dread - Compilacao.zip (mp3's - 11,35 MB)