Return to Snippet

Revision: 3335
at July 11, 2007 05:51 by 1man


Initial Code
/** @id codeFocus 
* @classDescription Focuses on the selected input and selects the value text. 
*/
var postcodeFocus = {
	grab:function(){
		if(!document.getElementById){return;};
		if(!document.getElementById('selected')){return;};
		var theInput = document.getElementById('selected');
		theInput.focus();
		theInput.select();
	}
}

Initial URL


Initial Description
For forms with a default value onload you don't want your users to have to select the value, delete it and then insert their own input.

This function focuses on a selected input, then it selects the default text so the user can easily type their own value.

Initial Title
Focus and Select a Form Input

Initial Tags
form

Initial Language
JavaScript