Return to Snippet

Revision: 38078
at December 24, 2010 10:10 by Jamie


Initial Code
// A simple, lightweight, on-the-fly script to handle the clearing and resetting of a text field
var searchField = document.getElementById('search');
var defaultText = searchField.value;
searchField.onfocus = function(){
    if( searchField.value == defaultText ){
        searchField.value = '';
    }
};
searchField.onblur = function(){
    if( searchField.value == '' ){
        searchField.value = defaultText;
    }
};

Initial URL

                                

Initial Description

                                

Initial Title
Clear Text Field of its default value, and return the original value

Initial Tags
search, text

Initial Language
JavaScript