2010-09-08 153 views
0

我有一个用于输入日期的文本框。现在,当用户以指定的格式输入日期时,如果用户给出的不是当前日期,我必须在客户端自己进行验证(当前日期是当用户输入时的“实际日期”)日期验证

回答

0
<form id="form1" runat="server"> 
    <div> 
    <table id="table1" runat="server" border="0" cellpadding="1" cellspacing="2"> 
    <tr> 
    <td> 
    <asp:Label id="lblDate" Text="Date" AssociatedControlID="txtDate" runat="server"></asp:Label> 
    </td> 
    <td> 
    <asp:TextBox ID="txtDate" runat="server"></asp:TextBox> 
    <asp:CompareValidator id="cmprDate" Text="(Invalid Date)" ControlToValidate="txtDate" Type="Date" Operator="DataTypeCheck" runat="server"></asp:CompareValidator> 
    </td> 
    </tr> 
    </table> 

    </div> 
    </form> 

尝试上面的代码。它在客户端验证日期。