还不如直接new Date()呢。

解决方案 »

  1.   


    刚给你写了一下.可以用.<script type="text/javascript">
    function ss(){
    var t = document.all.time.value;
    if(t.length==4){
    document.all.time.value+="-";
    }
    if(t.length==7){
    document.all.time.value+="-";
    }
    }
    </script>
    <input name="time" onkeypress="ss();">
      

  2.   

    用键盘事件判断一下
    <html>
    <head>
    <script language="javascript">
    function chege(){
    if(document.forms[0].te.value.length==4){
    var  techeck=document.forms[0].te;
    techeck.value+="-";
    }
    }
    </script>
    </head>
    <body>
    <form name="gege">
    <input type="text" name="te" onkeypress="chege();">
    </form>
    </body>
    </html>
      

  3.   

    <html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=shift_jis">
    <title>新しいページ 3</title>
    <script>
    function show()
    {
    var txt = document.getElementById("value");
    if(10<parseInt(txt.value)<2999)
    {
    txt.value = txt.value+"-";
    }
    }
    </script>
    </head><body>
    <input id="value" onchange="show()">
    </body></html>
    类似这样的么