Return to Snippet

Revision: 30991
at August 26, 2010 23:19 by andyweb


Initial Code
var formEl =  '#main .contact_form';
if( $(formEl).length >0 ){	
	var labelArray = new Array();	
	for(i=0 ; i<$(formEl+' .inputText').length ; i++){
		labelArray[i] = $(formEl+' .inputText:eq('+i+')').attr('value');		
	}	
	$(formEl+' .inputText').focus(
		function(){			
			index = $(formEl+' .inputText').index(this);			
			if( $(this).attr('value') == labelArray[index] ){			
				$(this).attr('value','');
			}
		}).blur(function(){
			index = $(formEl+' .inputText').index(this);
			if( ($(this).attr('value') == labelArray[index]) || ( $(this).attr('value') == '') ){	
				$(this).attr('value',labelArray[index]);
			}
		});	
}

Initial URL

                                

Initial Description
Show/hide labels on focus/blur when using form values as labels.

Initial Title
Form label value show/hide

Initial Tags

                                

Initial Language
jQuery