eSnippets.net, a code gallery for creating, saving and sharing all kinds of code snippets.

Clear Field on Focus — Javascript

Posted On: Saturday, May 10, 2014 at 9:48 AM

Replace "value" with the default value. If the field is selected, the default value will go away. If the user has previously changed the field value, it'll be left alone.

<input type="text" onfocus="if(this.value == 'value') { this.value = ''; }" value="value" />

You need to be logged in to comment! x

rpjs

Joined on Saturday, May 3, 2014
Contributed 29 Snippets

Get Social and Share

Tags