提示什么?
<input type="text">
<input type="text" onfocus="this.value='请输入密码:'"/>
这样??

解决方案 »

  1.   

    <input type="text" title="请输入" onfocus="this.value==''?this.value=this.title:''" onblur="this.value==this.title?this.value='':''">
      

  2.   

    <script> 
    function cls(){ 
    //捕获触发事件的对象,并设置为以下语句的默认对象 
    with(event.srcElement) 
        //如果当前值为默认值,则清空 
    if(value==defaultValue) value="" 

    function res(){ 
    //捕获触发事件的对象,并设置为以下语句的默认对象 
    with(event.srcElement) 
    //如果当前值为空,则重置为默认值 
    if(value=="") value=defaultValue 

    </script> 
    <input value="填写您的昵称" onfocus="cls()" onblur="res()"> 
    <input value="填写您的生日(1900-01-01)"  onfocus="cls()" onblur="res()">
    --------------------------------------
    请问怎样把上面改成文本框默认为空。插入光标是有提示,光标移出时清空文本框,
      

  3.   

    你的条件写反了。把你的两个函数名调一下就好了。<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html>
    <head>
    <title>Untitled</title>
    <script> 
    function cls(){ 
    //捕获触发事件的对象,并设置为以下语句的默认对象 
    with(event.srcElement) 
    //如果当前值为默认值,则清空 
    //if(value==defaultValue) value="" 
    if(value=="") value=defaultValue 

    function res(){ 
    //捕获触发事件的对象,并设置为以下语句的默认对象 
    with(event.srcElement) 
    //如果当前值为空,则重置为默认值 
    //if(value=="") value=defaultValue 
    if(value==defaultValue) value="" 

    </script>
    </head><body>Hello World!
    <Form>
    <input value="填写您的昵称" onfocus="cls()" onblur="res()"> 
    <input value="填写您的生日(1900-01-01)" onfocus="cls()" onblur="res()">
    </Form>
    </body>
    </html>
      

  4.   

    我想楼主要的是这种效果
    <input name=haha2 type=text>
    <input name=haha type=text onfocus="document.getElementById('mytips').style.visibility='visible';" onblur="document.getElementById('mytips').style.visibility='hidden';">
    <div id=mytips style="position:absolute;background-color:#ff0000;width:121;visibility:hidden;height:16;left:200; top:5">提示</div>
      

  5.   

    刚才看错了,
    改了你的函数,<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html>
    <head>
    <title>Untitled</title>
    <script> 
    function cls(){ 
    with(event.srcElement) 
    if(value==name) value="" 
    }function res(){ 
    with(event.srcElement) 
    if(value=="") value=name 

    </script>
    </head><body>
    Hello World!
    <Form>
    <input type="textbox" value="" onfocus="res()" onblur="cls()" size="40" name="填写您的昵称"> <br>
    <input type="textbox" value="" onfocus="res()" onblur="cls()" size="40" name="填写您的生日(1900-01-01)"> <br>
    </Form>
    </body>
    </html>添加了textbox的name属性。你好象就是困惑在这里。我测试通过了,
    测试环境:
    2000Pro
    IE6.0
      

  6.   

    哦,加上select就好了。<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html>
    <head>
    <title>Untitled</title>
    <script> 
    function cls(){ 
    with(event.srcElement) 
    if(value==name) value="" 
    }function res(){ 
    with(event.srcElement) 
    if(value=="") value=name 
    event.srcElement.select();

    </script>
    </head><body>
    Hello World!
    <Form>
    <input type="textbox" value="" onfocus="res();" onblur="cls()" size="40" name="填写您的昵称"> <br/>
    <input type="textbox" value="" onfocus="res()" onblur="cls()" size="40" name="填写您的生日(1900-01-01)"> <br/>
    </Form>
    </body>
    </html>你想要鼠标的,添加onmousedown事件就可以了。测试环境:
    2000Pro
    IE6.0