<HTML>
<HEAD>
<TITLE></TITLE>
<script>
var strOldDate = "10/15/2003";
var nOldDate = Date.parse(strOldDate);
function foo(){
if(date.value.length != 10)
alert("input errer");
else
{
var nNewDate = Date.parse(date.value);
if(isNaN(nNewDate))
alert("input errer");
else
alert(nOldDate == nNewDate)
}
}
</script>
</HEAD>
<BODY>
请输入日期(如10/15/2003):
<input id="date" type="text" value="10/15/2003" onblur="foo()">
</BODY>
</HTML>

解决方案 »

  1.   

    非常感谢!不过第一个日期的问题,我是用来查询的,包括(StartDate,EndDate)
    校验要达到:!=“”
                格式一定要( 0000-00-00)
                闰年的2月29天,其他的28天
                0<(1,3,5,7,8,10,12)(月的日期)<32
                 0<(4,6,9,11,)<31
                 startdate<enddate(主要是这个不好实现) (在javascript里好象没有字符串比较的方法)
      

  2.   

    isNaN 这个是什么功能的方法
      

  3.   

    打印且不显示打印按钮,功能全面
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML><HEAD><TITLE>打印确认</TITLE>
    <META http-equiv=Content-Type content="text/html; charset=gb2312">
    <STYLE media=print>.noprint {
    DISPLAY: none
    }
    </STYLE><META content="MSHTML 6.00.2800.1106" name=GENERATOR></HEAD>
    <BODY>
    <OBJECT id=factory style="DISPLAY: none" 
    codeBase=http://www.meadroid.com/scriptx/ScriptX.cab#Version=5,60,0,360 
    classid=clsid:1663ed61-23eb-11d2-b92f-008048fdd814 viewastext></OBJECT>
    <SCRIPT defer>
    function window.onload() {
      //factory.printing.paperSize = "A3"
      factory.printing.header = ""
      factory.printing.footer = ""
      factory.printing.portrait = false
      idPrint1.disabled = false; // enable UI button
      idPrint2.disabled = false;
      idPrint3.disabled = false;
      idPrint4.disabled = false;
      factory.printing.leftMargin = 0.75
      factory.printing.topMargin = 1.5
      factory.printing.rightMargin = 0.75
      factory.printing.bottomMargin = 1.5
      }
    </SCRIPT><DIV class=noprint><INPUT id=idPrint1 onclick=factory.printing.Print(false) type=button value=打印本页> 
    <INPUT id=idPrint2 onclick=factory.printing.PageSetup() type=button value=页面设置> <INPUT id=idPrint3 onclick=factory.printing.Preview() type=button value=打印预览> <INPUT id=idPrint4 onclick=window.close() type=button value=关闭窗口> </DIV><BR>
    <TABLE cellSpacing=0 cellPadding=0 width=720 align=center border=0>
      <TBODY>
      <TR>
        <TD bgColor=#0099ff>这里是你要打印的内容,上面的按钮不会被打印出来<BR>factory.printing.paperSize 
          = "A3" </TD></TR></TBODY></TABLE></BODY></HTML>