Clear default text from input boxes using Javascript

Providing labels is a great way to help users interact with your website properly. I like to put instructional text inside text boxes to save space. Users get annoyed when the text inside the box they click on does not disappear when they are ready to type. Users do not want to backspace default instructional text before typing in boxes, so some code is required to make this happen.

I would like to share two small Javascript functions. The first clears out default text box contents automatically when a user clicks on the box. The second restores the default instructional text if the user leaves the box empty.

Implement these functions using onfocus=”wash(this);” and onblur=”checkWash(this);” on your text input control. You may want to avoid the second function on text fields where input is optional, so the user can leave the text box blank.

function wash( element ){
if(element.value == element.defaultValue) element.value = '';
}

function checkWash( element ){
if(element.value == '') element.value = element.defaultValue;
}

Try it

Look, I made a demo!

Get Longitude and Latitude from Bing Maps

To get longitude and latitude coordinates from Bing Maps, follow these steps:

  1. Position the map center on your point of interest
  2. Type this into your web browser’s address bar:
    javascript:map.GetCenter()
  3. Hit enter or click an appropriate button to query the address

If you are using a browser with a lot of built-in security roadblocks like Internet Explorer, you may have to acknowledge security warnings before javascript code will execute.

Why are craigslist ads flagged flowchart

Today, I made a simple flowchart to describe how and why craigslist ads are flagged and removed.

http://www.gliffy.com/publish/1892404/

Next Page »

 

Thanks for reading!

You like? Subscribe to my
RSS RSS feed
or

Sign up for email updates:

Some Recent Updates