仿163注冊(cè)提示

字號(hào):


    <html>
    <head>
    <title>仿163注冊(cè)提示顯示-網(wǎng)站制作學(xué)習(xí)網(wǎng)</title>
    <script language="javascript">
    var forasp = new Object;
    forasp.f = function(obj,h)//obj是檢測(cè)的text文本框,h是自定義要顯示提示層距頂部的高度差,可以自行調(diào)節(jié)。
    {var t = document.getElementById("forasp_cn");
    t.style.top = 12 + h +"px";
    t.innerHTML=obj.title;//將顯示的title放到層里面
    t.style.display="";
    }
    forasp.cl = function(obj)
    {
    var t = document.getElementById("forasp_cn");
    if (obj.value.replace(/[^\x00-\xff]/g,"**").length > obj.l);//將中文替換為兩個(gè)字符
    {alert(obj.title+"長(zhǎng)度過長(zhǎng)!");obj.value="";obj.focus();}
    t.style.display="none";
    }
    </script>
    </head>
    <body>
    <p><input type="text" size = "25" onfocus="forasp.f(this,0);" onblur="forasp.cl(this)" l="10"><br><!--l表示內(nèi)容字符的長(zhǎng)度,title是顯示的內(nèi)容-->
    <input type="text" size = "25" onfocus="forasp.f(this,22);"  onblur="forasp.cl(this)" l="10"><br>
    <input type="text" size = "25" onfocus="forasp.f(this,45);"  onblur="forasp.cl(this)" l="10"><br>
    <input type="text" size = "25" onfocus="forasp.f(this,68);"  onblur="forasp.cl(this)" l="10"><br>
    <input type="text" size = "25" onfocus="forasp.f(this,91);"  onblur="forasp.cl(this)" l="10"><br></p><br>
    <div id="forasp_cn" >這里是隱藏的一個(gè)層,主要用來顯示提示內(nèi)容</div>
    </body>
    </html>