Return to Snippet

Revision: 27861
at June 25, 2010 07:25 by jonkemp


Initial Code
$("#searchbox").focus(function () { 
	if ($("#searchbox").val() == "Blah Blah Blah") {
		$("#searchbox").val("");	
	}
});

Initial URL

                                

Initial Description
This requires jQuery. The script checks to see if default text is present in a text field on focus. If it is, then it clears the text. Otherwise, it leaves user entered text intact. This is normally used for a search box.

Initial Title
Clear Text Field on Focus

Initial Tags
javascript, jquery

Initial Language
JavaScript