Return to Snippet

Revision: 11058
at June 22, 2009 20:08 by 1man


Updated Code
$("input[name=forname], input[name=surname]").focus(function(){
	var defaultText = $(this).val();
	if(defaultText === "Forename" || defaultText === "Surname"){
		$(this).select();
	}
});

Revision: 11057
at January 22, 2009 05:32 by 1man


Initial Code
$("input[name=initial], input[name=surname]").focus(function(){
			var defaultText = $(this).val();
			if(defaultText === "Forename" || defaultText === "Surname"){
				$(this).select();
			}
		});

Initial URL

                                

Initial Description
Click on an input field with a prefilled value, if that value equals the default then select it, if not leave it as it was. Relies on jQuery.

Initial Title
jQuery Input value select

Initial Tags
form, javascript, jquery

Initial Language
JavaScript