Posts filed under 'JavaScript'

Automatically empty a search box on focus with jQuery

Marc-Antoine Ross April 23rd, 2009 Add comment

This simple Javascript snippet will bind the focus event to any element that has a “clearSearch” css class. On focus, the field is emptied if it is the default value. On blur, it will put back the default value if nothing was entered. Very simple and unobtrusive. You can use it on your registration forms as well!

TAXI.clearField = function() {
    $(’.clearSearch’).bind(’focus’, function(){
        if( this.value == this.defaultValue ) {
            this.value = ”";
        }
    });
    $(’.clearSearch’).bind(’blur’, function(){
        if( !this.value.length ) {
            this.value = this.defaultValue;
        }
    });
};

jQuery Cheat Sheet

Marc-Antoine Ross April 22nd, 2009 1 comment

Country jQuery Autocomplete plugin

Marc-Antoine Ross December 21st, 2008 22 comments

XHTML: Open a link in a new window - V2

Marc-Antoine Ross February 3rd, 2007 Add comment

Prototype Cheat Sheet

Marc-Antoine Ross March 17th, 2006 Add comment

An indexable popup… it’s possible!

Mario Laflamme March 10th, 2006 1 comment

XHTML: Open a link in a new window

Mario Laflamme March 9th, 2006 1 comment

Schedule

February 2012
M T W T F S S
« Jul    
 12345
6789101112
13141516171819
20212223242526
272829