Home Daily Marketing Tips About Me Work With Me

Marketing & Design Blog

Internet Marketing, SEO, Blogging, Social Media, Lead Generation and Analytics

Clear Input Field Value When Selected

Often when creating forms on a website it is helpful to place descriptive text with some of the form fields to help the user understand what they should type in the box. If this descriptive text is not cleared automatically when the user begins to type, sometimes this will hinder them more than it helps.

Using a simple JavaScript function you can automatically clear the example values from the input box when the user clicks into the field.

For an example of how this works, look at my newsletter fields to the right.

This technique can easily be used to clear the contents of any input box.

All you have to do, is add a small bit of JavaScript to your input like this:

<input value="Your Comment" onclick="this.value=''" type="text">

There are a lot of other ways to do this… Post yours below.

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

8 Comments »

  1. Brrrrilliant!!

    thanks, this is exactly what i wanted ;)

    Comment by anon — October 25, 2006 @ 9:39 am

  2. Perfect! Thanks mate!

    Comment by Jordan Moore — January 11, 2009 @ 6:10 am

  3. Thank you :)

    This little script solved a long boring problem, I’ve had.
    The working script can now also be seen at my site.

    You sure provided something of value.

    Michael’s last blog post… It’s Not Safe

    Comment by Michael — February 27, 2009 @ 5:50 am

  4. You’re welcome ;)

    Comment by zacheos — February 27, 2009 @ 7:05 am

  5. How do I make the value return to the input field, when clicking somewhere else, if I didn’t enter any text(like this: http://buildinganonline.com/contact)?

    Comment by Michael — March 26, 2009 @ 1:45 am

  6. Thnks for this.

    Comment by Cluj — June 24, 2009 @ 2:48 am

  7. Thanks for this tip! ;) Bookmarked this page. :)

    Comment by Luna — October 7, 2009 @ 10:23 pm

  8. Very useful and quick solution. Perfect for what I was looking for… Clears the value like a charm.

    Comment by Devin Walker — April 2, 2010 @ 1:56 pm

RSS feed for comments on this post. TrackBack URL

Leave a comment

logo design brand development

We have simplified the typical logo ordering process, put you in direct contact with the artist, made getting additional branding products and websites easy, and rounded it all off with high quality printing services at fantastic rates... Learn more

website design development

We have made getting a completely dynamic website built on the WordPress content management system with a theme of your choice easy. We integrate your logo into the site design and offer great add-ons at amazing prices - giving you a range of choices on design and layout... Learn more

search engine optimization

We have expert SEO consultants ready to tackle any aspect of your search engine marketing and optimization needs. We take pride in the ability to custom build an Internet marketing campaign that is perfectly suited to your needs.... Read more


© Copyright 2003-2010 Zach Graeve and Expert Online Services, LLC. All Rights Reserved.
 Subscribe, RSS, Comments RSS, XML Sitemap, Privacy Policy