Hello, everyone.
I've got a keyword search form that is appearing on every page. The text input defaults to a value of "Search...".
I've written code that is supposed to bind to the input a focus and a blur. On focus, if the value == "Search...", make the value blank. On blur, if the value == "", make the value "Search...". If the value is anything else, don't do anything.
The blur part works just fine; but if you type a word into the input, then blur, then put focus back on the input, it still blanks the value. I can type the word "account" into the input, blur (keeping the value "account") and then put focus back and "account" disappears.
Here is my code that is within $(document).ready(). Can anyone see what I'm doing incorrectly?
Code:
$('#searchBox').bind({
focus: function(){
if($(this).val().replace(/^\s*|\s*$/gi,'') == "Search..."){$(this).val('');}
}
blur: function(){
if($(this).val().replace(/^\s*|\s*$/gi,'') == ""){$(this).val('Search...');}
}
});
Thanks,