radDatetimePicker - Compare Validator

6 posts, 0 answers
  1. Mario Turcotte
    Mario Turcotte avatar
    15 posts
    Member since:
    Nov 2007

    Posted 22 Jul 2008 Link to this post

    Hello, hope someone can  help me find a decent soultion to my problem. I have a form with 4 different radDateTimePicker, they are used to create an event. For each entry I have to compare the Date and time of the previous entry. Because of the control format Compare Validator doesn't work.

    I'm using radCalendar 2.2.5

    Description of the 4 Date Time Pickers

    1) Date that the Event will be published (today and future date)
    2) Date the Event Start (GreaterThenEqual then #1 Date time Picker)
    3) Date the Event End (GreatherThen then #2 Date Time Picker)
    4) Date the Event is Archived (GreatherThen #3 Date Time Picker)

    I've thought of using two different controls radDatePicker and radTimePicker, but I will have to add too much client side to the form. My form already have over 60 controls.

    Any help suggestion is welcome.

    Thanks, Mario
  2. Plamen Peshev
    Admin
    Plamen Peshev avatar
    885 posts

    Posted 25 Jul 2008 Link to this post

    Hello Mario,

    You can use a CompareValidator to ensure that the second date is greater than the first one. This online example shows how to use CompareValidator with RadDatePicker/RadDateTimePicker control

    Sincerely yours,
    Plamen
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Marino
    Marino avatar
    2 posts
    Member since:
    Aug 2008

    Posted 07 Aug 2008 Link to this post

    I'm using telerik:RadDateTimePicker and the CompareValidator doesn't work with this control.

    I copy the validator code from example and it doesn't work.

    How can I compare two RadDateTimePicker fields ?
  4. Konstantin Petkov
    Admin
    Konstantin Petkov avatar
    1911 posts

    Posted 08 Aug 2008 Link to this post

    Hello Marino,

    Can you please share your markup? We will review it and get back with our findings.

    Sincerely yours,
    Konstantin Petkov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  5. Marino
    Marino avatar
    2 posts
    Member since:
    Aug 2008

    Posted 08 Aug 2008 Link to this post

    Thank you for reply.

    I make some tests and detect that CompareValidator doesn't work with date and time. It only works with date.

    To compare dateTime I need to use the CustomValidator and write a javascript function to validate the fields.


    []'s

    Marino Mena
  6. Mario Turcotte
    Mario Turcotte avatar
    15 posts
    Member since:
    Nov 2007

    Posted 08 Aug 2008 Link to this post

    @Plamen, thans for your reply, however the link you direct me on is using Date Picker only, which has never been an issue for me.

    I work with the Telerik objects since two years now, and I found that sometimes objects didn't react as expected. Most of the time I had to start to play with the object on a blank page and voila! it works on my original page. It has to do with versionning I guess, since I work in an environment where two to 5 developpers are working on the same project and someone update an object. We are using Source Safe for the past 12 years and honestly I start to dislike it. Anyhow here is the code I finally came with, pretty straight forward.

    <rad:RadDateTimePicker ID="rdDateTimeOccurrence" runat="server" Skin="Default" Width="175"></rad:RadDateTimePicker>                                                  
    <rad:RadDateTimePicker ID="rdDateTimeDiscovery" runat="server" Skin="Default"></rad:RadDateTimePicker>                                                  
    <rad:RadDateTimePicker ID="rdDateTimeStopped" runat="server" Skin="Default"></rad:RadDateTimePicker>                                                  
    <rad:RadDateTimePicker ID="rdDateTimeCleanedUp" runat="server" Skin="Default"></rad:RadDateTimePicker>                                                  
     
    <asp:RequiredFieldValidator ID="valDateTimeOccurrence" runat="server" ControlToValidate="rdDateTimeOccurrence" Display="None" ErrorMessage="Error Message"></asp:RequiredFieldValidator> 
    <asp:RequiredFieldValidator ID="valDateTimeDiscovery" runat="server" ControlToValidate="rdDateTimeDiscovery" Display="None" ErrorMessage="Error Message"></asp:RequiredFieldValidator> 
    <asp:CompareValidator ID="valDateTimeOccurrenceDiscovery" runat="server" ControlToCompare="rdDateTimeOccurrence" ControlToValidate="rdDateTimeDiscovery" Operator="GreaterThanEqual" Display="None" ErrorMessage="Error Message"></asp:CompareValidator> 
    <asp:RequiredFieldValidator ID="valDateTimeStopped" runat="server" ControlToValidate="rdDateTimeStopped" Display="None" ErrorMessage="Error Message"></asp:RequiredFieldValidator> 
    <asp:CompareValidator ID="valDateTimeDiscoveryStopped" runat="server" ControlToCompare="rdDateTimeDiscovery" ControlToValidate="rdDateTimeStopped" Operator="GreaterThanEqual" Display="None" ErrorMessage="Error Message"></asp:CompareValidator> 
    <asp:RequiredFieldValidator ID="valDateTimeCleanedUp" runat="server" ControlToValidate="rdDateTimeCleanedUp" Display="None" ErrorMessage="Error Message"></asp:RequiredFieldValidator> 
    <asp:CompareValidator ID="valDateTimeStoppedCleanedUp" runat="server" ControlToCompare="rdDateTimeStopped" ControlToValidate="rdDateTimeCleanedUp" Operator="GreaterThanEqual" Display="None" ErrorMessage="Error Message"></asp:CompareValidator>                                                  
    <asp:RequiredFieldValidator ID="valReportedby" runat="server" ErrorMessage="Error Message" ControlToValidate="txtReportedby" Display="None"></asp:RequiredFieldValidator> 
    <asp:RequiredFieldValidator ID="valPhoneNumber" runat="server" ErrorMessage="Error Message" ControlToValidate="txtPhoneNumber" Display="None"></asp:RequiredFieldValidator> 

    Each Date/Time entry is required and the following Date/Time is compare to the previous Date/Time. It works like a charm now :) This is with Version 2.2.5.
Back to Top