格式为2005-01-01  2005/01/01   哪个都行  都能验证就更好了

解决方案 »

  1.   

    用CompareValidator
    operator设成DateTypeCheck
    type设成Date
      

  2.   

    function onlyDate()// 在public/common.js中定义
    {
    var src = window.event.srcElement ;//相当于日期的输入框

    if ( 8 == window.event.keyCode ) return true;

    if (src.value.length > 4 && src.value.indexOf("-") < 1)
    src.value = "";

    if (src.value.length == 4 || src.value.length == 7 )
    src.value = src.value + "-"

    if (src.value.length == 10 && src.maxLength != 10)
    src.value = src.value + " "

    if (src.value.length == 13)
    src.value = src.value + ":"
    }
    <script language="javascript" src="../public/common.js"></script>
    <script language="javascript">
    <!--
        function window.onload()
       {
    Form1.txtdApplyDate.onkeyup =onlyDate;
    Form1.txtdApplyDate.onkeypress =CheckDate;
      }
        function txtdPartInDate_onblur()
      {
    if ( Form1.txtdPartInDate.value == "") return false;
    if ( isDate(Form1.txtdPartInDate.value) == false )
    {
       alert("请输入正确的日期");
       Form1.txtdPartInDate.focus();
       return;
    }
       }
    //-->
    </script>
      

  3.   

    上面错了,对不起。^((((31\/(0?[13578]|1[02]))|((29|30)\/(0?[1,3-9]|1[0-2])))\/
    (1[6-9]|[2-9]\d)?\d{2})|(29\/0?2\/(((1[6-9]|[2-9]\d)?(0[48]|
    [2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))|
    (0?[1-9]|1\d|2[0-8])\/((0?[1-9])|(1[0-2]))\/((1[6-9]|[2-9]\d
    )?\d{2})) (20|21|22|23|[0-1]?\d):[0-5]?\d:[0-5]?\d$Matches:  [29/02/2004 20:15:27], [29/2/04 8:9:5], [31/3/2004 9:20:17]
      

  4.   

    (((0[1-9]|[12][0-9]|3[01])([/])(0[13578]|10|12)([/])(\d{4}))
    |(([0][1-9]|[12][0-9]|30)([/])(0[469]|11)([/])(\d{4}))|((0[1
    -9]|1[0-9]|2[0-8])([/])(02)([/])(\d{4}))|((29)(\.|-|\/)(02)(
    [/])([02468][048]00))|((29)([/])(02)([/])([13579][26]00))|((
    29)([/])(02)([/])([0-9][0-9][0][48]))|((29)([/])(02)([/])([0
    -9][0-9][2468][048]))|((29)([/])(02)([/])([0-9][0-9][13579][
    26])))Matches:  [28/12/2003], [28/02/2003], [29/02/2000]