Return to Snippet

Revision: 42991
at March 14, 2011 22:53 by jimbo


Initial Code
function activate_field(field,txt)  
 {
	if (field.value === txt) {
		field.value = "";
	}
	else { $(field).select(); }
 }

/*
 * call with an onfocus event
 * example: 
 * <input type="text" onfocus="activate_field(this,\'City\')" 
 *   id="city" name="city" value="City" />'
 */

Initial URL


Initial Description
Clear a field on entry if the default text matches a supplied value. Generic to any field.

Initial Title
Clear HTML Form Field on Entry

Initial Tags
form

Initial Language
JavaScript