我要在登录部分输入密码的文本框内有文字提示“6位数字”,
用户点击文本框的时候可以输入密码,
光标移出文本框的时候提示信息要再次显示。顺便提一下,我做的显示信息在密码框都是显示成×××××了。请大家帮忙解决一下啊?

解决方案 »

  1.   

    如果使用的是swing或者awt组件的话,可以使用"当前的文本框对象".setToolTipText("6位数字");
    如果是别的组件我没有试过,你自己可以尝试一下,希望你能够成功
      

  2.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
     <HEAD>
      <TITLE> New Document </TITLE>
      <script>
     function change(obj){
     obj.style.display = "none";
     if(obj.type=="text")
    document.getElementById('pass').style.display = "block";
    else
    document.getElementById('txt').style.display = "block";
     }
      </script>
     </HEAD> <BODY>
    <input id="txt" type="text"  value="6位数字" onfocus="change(this)" style="width:150px;height:20px"> 
    <input id="pass" type="password" value="" style="display:none;width:150px;height:20px" onblur="change(this)"> <script> 
    </script> 
     </BODY>
    </HTML>
      

  3.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
     <HEAD>
      <TITLE> New Document </TITLE>
      <script>
     function change(obj){
     obj.style.display = "none";
     if(obj.type=="text")  {  
        document.getElementById('pass').style.display = "block";
    document.getElementById('pass').focus();//加上
        }else{
        document.getElementById('txt').style.display = "block";
    }
     }
      </script>
     </HEAD> <BODY>
    <input id="txt" type="text"  value="6位数字" onfocus="change(this)" style="width:150px;height:20px"> 
    <input id="pass" type="password" value="" style="display:none;width:150px;height:20px" onblur="change(this)"> <script> 
    </script> 
     </BODY>
    </HTML>
      

  4.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
     <HEAD>
      <TITLE> New Document </TITLE>
      <script>
     function change(obj){
     if(obj.type=="text"){
        obj.style.display = "none";
        document.getElementById('pass').style.display = "block";
        document.getElementById('pass').value="";
        document.getElementById('pass').focus();//加上
     }else{
        var pass = document.getElementById('pass').value;
        if(pass.length<1){
          obj.style.display = "none";
          document.getElementById('txt').style.display = "block";
        }
     }
     }
      </script>
     </HEAD> <BODY>
    <input id="txt" type="text"  value="6位数字" onfocus="change(this)" style="width:150px;height:20px">
    <input id="pass" type="password" value="" style="display:none;width:150px;height:20px" onblur="change(this)"><script>
    </script>
     </BODY>
    </HTML>
      

  5.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
     <HEAD>
      <TITLE> New Document </TITLE>
      <script>
     function change(obj){
     obj.style.display = "none";
     if(obj.type=="text")  {  
        document.getElementById('pass').style.display = "block";
        document.getElementById('pass').focus();//加上
        }else{
        document.getElementById('txt').style.display = "block";
        }
     }
      </script>
     </HEAD> <BODY>
    <input id="txt" type="text"  value="6位数字" onfocus="change(this)" style="width:150px;height:20px"> 
    <input id="pass" type="password" value="" style="display:none;width:150px;height:20px" onblur="change(this)"> <script> 
    </script> 
     </BODY>
    </HTML>
      

  6.   

    LZ的目的是什么,按LZ这样的想法这样写密码还有什么意义吗?提交上去的值不管你输入什么密码都是
    "6位数字"了,你用隐藏域保存了密码信息?
      

  7.   


    <HTML>
    <HEAD>
    <TITLE>ToolTip</TITLE>
        <script>
        function showToolTip(obj){
            document.getElementById("tipform").style.display="";
        }    function hideToolTip(obj){
            document.getElementById("tipform").style.display="none";
        }
        </script>
    </HEAD>
    <BODY>
    <input id="pass" type="password" value="" size=10 maxLength=6  
        onmouseout="hideToolTip(this)" onmouseover ="showToolTip(this)"> 
    <div UNSELECTABLE="on" id="tipform"   
        style="position:absolute;left:10;top:40;width:60px;background-color:#ffffC0;
        height:12px;z-index:1;display='none';">6位数字</div>
    <script> 
    </script> 
    </BODY>
    </HTML>
      

  8.   

    按楼主的要求,要反过来<HTML>
    <HEAD>
    <TITLE>ToolTip</TITLE>
        <script>
        function showToolTip(obj){
            document.getElementById("tipform").style.display="";
        }    function hideToolTip(obj){
            document.getElementById("tipform").style.display="none";
        }
        </script>
    </HEAD>
    <BODY>
    <input id="pass" type="password" value="" size=10 maxLength=6  
        onmouseout="showToolTip(this)" onmouseover ="hideToolTip(this)"> 
    <div UNSELECTABLE="on" id="tipform"   
        style="position:absolute;left:10;top:40;width:60px;background-color:#ffffC0;
        height:12px;z-index:1;display='';">6位数字</div>
    <script> 
    </script> 
    </BODY>
    </HTML>