views:

537

answers:

2

Here's my code:

<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>

And the results:

  • 01/01/2008 Doesn't pass
  • 02/02/2008 Doesn't pass
  • 11/11/2000 Passes
  • 08/08/2001 Passes

What am I missing here?

+1  A: 

You need to increase MaximumValue to a date which is greater than that of your tests. Specifically, MaximumValue should be set to 12/31/2200. You've fat-fingered the MaximumValue.

Ben Griswold
Selected for using the term "fat fingered"
danieltalsky
+1  A: 

The example you gave seems to have a typo. You specify the MaximumDate as '31/12/2002' instead of '31/12/2200'.

BlackMael