在程序中加了个日历控件,如下调用
          <asp:TextBox ID="TBDate" runat="server" Width="136px" Onfocus="calendar()" AutoPostBack="True"></asp:TextBox>
在后台程序中判断
   Protected Sub TBDate_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TBDate.TextChanged
        If format(TBDate.Text,"YYYY-mm-dd") < Format(Now, "yyyy-mm-dd") Then
            Response.Write("<script>alert('选择的日期无效')</script")
        End If
    End Sub
在textchanged设了断点调试,为什么运行不到这段程序呢?

解决方案 »

  1.   

    "(((^((1[8-9]\\d{2})|([2-9]\\d{3}))([-\\/\\._])(10|12|0?[13578])([-\\/\\._])(3[01]|[12][0-9]|0?[1-9])$)|(^((1[8-9]\\d{2})|([2-9]\\d{3}))([-\\/\\._])(11|0?[469])([-\\/\\._])(30|[12][0-9]|0?[1-9])$)|(^((1[8-9]\\d{2})|([2-9]\\d{3}))([-\\/\\._])(0?2)([-\\/\\._])(2[0-8]|1[0-9]|0?[1-9])$)|(^([2468][048]00)([-\\/\\._])(0?2)([-\\/\\._])(29)$)|(^([3579][26]00)([-\\/\\._])(0?2)([-\\/\\._])(29)$)|(^([1][89][0][48])([-\\/\\._])(0?2)([-\\/\\._])(29)$)|(^([2-9][0-9][0][48])([-\\/\\._])(0?2)([-\\/\\._])(29)$)|(^([1][89][2468][048])([-\\/\\._])(0?2)([-\\/\\._])(29)$)|(^([2-9][0-9][2468][048])([-\\/\\._])(0?2)([-\\/\\._])(29)$)|(^([1][89][13579][26])([-\\/\\._])(0?2)([-\\/\\._])(29)$)|(^([2-9][0-9][13579][26])([-\\/\\._])(0?2)([-\\/\\._])(29)$)))|\\d{1,6}"这个正则表达式,判断日期合法性的。比如你输入08-02-31,就不会通过。