RadDateTimePicker validation

6 posts, 0 answers
  1. Prasad
    Prasad avatar
    7 posts
    Member since:
    Nov 2010

    Posted 14 Dec 2010 Link to this post

    RadDateTimepicker compare validation is not working properly even though it works fine for "RadDatePicker".can any one give me a solution for this? 
    Thank you .
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 15 Dec 2010 Link to this post

    Hello Prasad,

     I am not sure about your issue. Here is the code that I tried and it worked for me.

    ASPX:
    <telerik:RadDateTimePicker ID="RadDateTimePicker1" runat="server" Skin="Windows7">
    </telerik:RadDateTimePicker>
    <telerik:RadDateTimePicker ID="RadDateTimePicker2" runat="server" Skin="Windows7">
    </telerik:RadDateTimePicker>
    <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="RadDateTimePicker1" EnableClientScript="true" ControlToValidate="RadDateTimePicker2" ErrorMessage="GreaterThan" Type="String" Operator="Equal">
    </asp:CompareValidator>

    Please paste your code if it doesn't help.

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Andrew Dixon
    Andrew Dixon avatar
    15 posts
    Member since:
    Apr 2010

    Posted 16 Dec 2010 Link to this post

    I'm having the same problem.  I recently change from using RadDatePicker to RadDateTimePicker and my compare validator has stopped working.

    <telerik:RadDateTimePicker ID="rdtp_Start" runat="server" Width="200px">
        <DateInput ID="DateInput3" runat="server" DateFormat="<%$ Resources:Globals, DATETIME_FORMAT %>" DisplayDateFormat="<%$ Resources:Globals, DATETIME_FORMAT %>" ></DateInput>
        <TimeView ID="TimeView2" runat="server" StartTime="00:00:00" Interval="00:30:00" EndTime="23:45:00" Columns="4" RenderDirection="Vertical" />
    </telerik:RadDateTimePicker>
    <asp:RequiredFieldValidator ID="rfv_Start" runat="server" ErrorMessage="Please select a start date" ControlToValidate="rdtp_Start"></asp:RequiredFieldValidator>
     
    <telerik:RadDateTimePicker ID="rdtp_End" runat="server" Width="200px">
        <DateInput ID="DateInput1" runat="server" DateFormat="<%$ Resources:Globals, DATETIME_FORMAT %>" DisplayDateFormat="<%$ Resources:Globals, DATETIME_FORMAT %>" ></DateInput>
        <TimeView ID="TimeView1" runat="server" StartTime="00:00:00" Interval="00:30:00" EndTime="23:45:00" Columns="4" RenderDirection="Vertical" />
    </telerik:RadDateTimePicker>
    <asp:RequiredFieldValidator ID="rfv_End" runat="server" ErrorMessage="Please select an end date" ControlToValidate="rdtp_End"></asp:RequiredFieldValidator>
    <asp:CompareValidator ID="cv_End" runat="server" ErrorMessage="End date must be after start date" EnableClientScript="true" ControlToValidate="rdtp_End" ControlToCompare="rdtp_Start" Type="Date" Operator="GreaterThan" ></asp:CompareValidator>

    I've also tried a CustomValidator and had no luck with that either.

    Thanks
    Andrew
  5. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 22 Dec 2010 Link to this post

    Hello Prasad,

    The RadDateTimePicker could not be correctly validated with Compare Validator due to the structure of the control. In order to handle the required functionality you should use Custom Validator. Please find attached a sample application which demonstrates this scenario. 


    Regards,

    Maria Ilieva
    the Telerik team

     

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  6. TheJGV
    TheJGV avatar
    1 posts
    Member since:
    Jan 2013

    Posted 16 Jan 2013 Link to this post

    Can RadDateTimePicker work with RangeValidator in order to validate MinDate and MaxDate values to RadDateTimePicker?

    Can you please provide some example?

    Thank you
    juve
  7. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 16 Jan 2013 Link to this post

    Hi,

    With reference to this forum thread, Besides the visible input field that the user can type into, the RadDatePicker registers a hidden input field that is used for validation by the respective validation controls. When you set MinDate / MaxDate for the datepicker control and enter an invalid date (out-of-range), you can still see the erroneous output in the visible input field but the validation field (used by the validator controls) remains empty (after all there is NO valid selected date at the moment). Therefore RangeValidator is not activated as the only control that validates empty string is the RequiredFieldValidator.

    Thanks,
    Princy
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017