This is a migrated thread and some comments may be shown as answers.

Problem with DatePicker RangeAttribute validation

0 Answers 58 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Christian
Top achievements
Rank 1
Christian asked on 10 Aug 2011, 11:48 AM

I have decorated a property on a model with a RangeAttribute. After doing so I have noticed the following problems:

  1. After entering a valid date and then trying to submit the form, the client side validation indicates that the date entered falls outside the range.
  2. Entering ANY date by typing the date directly into the input element, when tabbing to another element causes client side validation to indicate that the date entered falls outside the range.

Here's how to reproduce the problem (at least on my machine):

  1. In the Telerik MVC demo application, decorate the OrderInfoDto.DeliveryDate with a range attribute. For example:
    [DisplayName("Delivery date")]
    [DataType(DataType.Date)]
    [Required]
    [Range(typeof(DateTime), "2011-Jan-01", "2011-Jan-10")]
    public DateTime? DeliveryDate
    {
        get;
        set;
    }
  2. Compile and then browse to the demo page for the datepicker/clientvalidation.
  3. To reproduce the first problem I observed:
    1. enter valid input into the 'Delay' and 'Order date time'
    2. enter a valid date using the picker (I chose 1-Jan-2011)
    3. click on the save button
    4. you will see that the validation message is displayed for the 'Delivery date' - this is incorrect as the date does fall within the range declared. You will also note that a post to the server did not occur ie client side validation stopped the post
  4. To reproduce the second problem I observed:
    1. type ANY date into the 'Delivery date' (I chose 1/1/2011)
    2. hit tab and you should see that the validation message is displayed for the 'Delivery date' - this is incorrect.

My setup is as follows:
Windows 7 prof (32 bit)
Firefox 3.6.17
Region and and language - format English (United Kingdom)
Telerik MVC 2011 Q2
No other alterations to the Telerik mvc demo were made

I also tried to reproduce these problems on IE9 (9.0.8112.16421). I was able to reproduce the first problem, but not the second problem. In IE9 typing in a valid date and tabbing out of the input element, the date is considered acceptable ie no validation message is displayed.

I have attached a screen shot demonstrating the second problem. This is after typing in 1/4/2011 (US format) and pressing tab. I then opened the picker just to further demonstrate the date that has been entered.

Tags
Date/Time Pickers
Asked by
Christian
Top achievements
Rank 1
Share this question
or