如何未点击密码提示框的时候密码框里有汉字的提示信息,点击密码框提示信息消失,并且输密码的时候变为**********

解决方案 »

  1.   

    <head>
    <style type="text/css">
    .password{width:150px;}
    .hint{color:#ccc;}
    .hidden{display:none;}
    </style>
    <script type="text/javascript">
    function password_hint_focus(sender) {
    sender.className = "hidden";
    var input = document.getElementById("password_input");
    input.className = "password";
    input.focus();
    }function password_input_blur(sender) {
    if (!sender.value) {
    sender.className = "hidden";
    var hint = document.getElementById("password_hint");
    hint.className = "password hint";
    }
    }
    </script>
    </head>
    <body>
    <form>
    密码:
    <input id="password_hint" class="password hint" type="text" value="请输入密码..." onfocus="password_hint_focus(this)"/>
    <input id="password_input" class="hidden" type="password" name="password" title="请输入密码..." onblur="password_input_blur(this)"/>
    </form>
    </body>