Code
<style>
html,body{margin:200px 400px;}
#search{color:#aaa;border:1px solid #CC0000;padding:1px; }
</style>
</head>
<body>
<input type="text" value="请输入关键字" id="search" />
</body>
<script language="javascript">
var s=document.getElementById("search");
s.onfocus=function(){if(this.value==this.defaultValue)this.value=''};
s.onblur=function (){if(/^\s*$/.test(this.value)){this.value=this.defaultValue;this.style.color='#aaa'}}
s.onkeydown=function(){ this.style.color='#333'}
</script>
<style>
html,body{margin:200px 400px;}
#search{color:#aaa;border:1px solid #CC0000;padding:1px; }
</style>
</head>
<body>
<input type="text" value="请输入关键字" id="search" />
</body>
<script language="javascript">
var s=document.getElementById("search");
s.onfocus=function(){if(this.value==this.defaultValue)this.value=''};
s.onblur=function (){if(/^\s*$/.test(this.value)){this.value=this.defaultValue;this.style.color='#aaa'}}
s.onkeydown=function(){ this.style.color='#333'}
</script>