Natedesigns





Form Value Remove – Improve UI

This code was developed to work within contact / search or other such forms where you don’t want the user to have to delete existing data in the form. It should be erased onFocus of the text box.

//Looks for field length
if($('input').length >= 1){
	//Store inputs in array
	var input = $('input');
    //Loop through array
    $(input).each(function(){
        var value = $(this).val();
            //store this iterative items value
        $(this).focus(function(){
	    $(this).val('');
                //OnFocus delete value
        });

        $(this).blur(function(){
           if ($(this).val()=="") {
              $(this).val(value);
                  //If value still empty, return loaded value.
           }
        });
    });
}