Hi,

I did this here:

/* get default value of any <input value="this here"> and make it disappear 
when the user focusses the input field
when the focus is taken from that field (blur), do this:
if nothing was entered by the user, set back the default value,
otherwise don't mess with the users input  */

$('input').focus(function(){
        var defaultText = $(this).val();
        $(this).val('');

        $("input").blur( function () {
        var userInput = $(this).val();

                if (userInput == ''){
                        $(this).val(defaultText);
                }
        });

});

on this HTML:

<div id="search">
<form action="/portal/wps/portal/PortalSearch">
<label for="searchFor">Search: </label>
<input name="searchFor" class="inputField" id="searchFor" type="text" 
value="Search">
<input type="image" src="theme/images/btn_search.gif" alt="go">
</form>
</div><!-- #search END -->

Is that what you want to do? I guess it could be optimized, though....

Regards
Michael



Original message Donnerstag, 17. Juli 2008, 18:19:

> Is there a plugin for this by chance? I know it's pretty quick to write, but
> wanted to find out if someone's already done it better than I could.
>  
> Also, would toggle() work for this sort of thing? Is there a focus/blur
> toggle in the jQuery core?






Reply via email to