1
這裏是我的代碼:如何使用ASP.net asp:RangeValidator來正確驗證日期?
<asp:TemplateField HeaderText="* License Setup Date">
<EditItemTemplate>
<asp:RequiredFieldValidator ID="LicenseSetupDateRequired"
ErrorMessage="License Setup Date can't be blank."
ValidationGroup="EditClientDetails"
ControlToValidate="BeginDate"
Text="*!"
Display="Dynamic"
runat="server"></asp:RequiredFieldValidator>
<asp:RangeValidator ID="LicenseSetupDateRange"
ErrorMessage="License Setup Date needs to be a date between 01/01/2000 and 12/31/2200"
ValidationGroup="EditClientDetails"
ControlToValidate="BeginDate"
MinimumValue="01/01/2000"
MaximumValue="12/31/2002"
Type="Date"
Text="*!" Display="Dynamic" runat="server"></asp:RangeValidator>
<asp:TextBox ID="BeginDate" MaxLength="10"
Text='<%# Bind("BeginDate", "{0:MM/dd/yyyy}") %>'
runat="server"></asp:TextBox>
<span class="fieldNote">(mm/dd/yyyy format)</span>
</EditItemTemplate>
</asp:TemplateField>
而且結果:
- 01/01/2008未通過
- 2008年2月2日未通過
- 11/11/2000通行證
- 2001年8月8日通行證
我在這裏錯過了什麼?
選擇使用術語「胖指」 – danieltalsky 2008-12-13 03:23:12