Comparing two raddatepicker

6 posts, 0 answers
  1. Balaji
    Balaji avatar
    5 posts
    Member since:
    Aug 2011

    Posted 25 Aug 2011 Link to this post

    Hi,

    I want to compare dates of two raddatepicker in javascript. How can I do?
     
    Scenario :

    If startdate > enddate
    alert("start date is greater than end date");

    Thanks,
    Balaji
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 26 Aug 2011 Link to this post

    Hello Balaji,

    You can achieve this easily by using CompareValidator.
    aspx:
    <telerik:RadDatePicker  ID="RadDatePicker1" runat="server">
    </telerik:RadDatePicker>  
    <telerik:RadDatePicker ID="RadDatePicker2" runat="server">
    </telerik:RadDatePicker>
    <asp:CompareValidator ID="CompareValidator1" Operator="GreaterThan" ControlToValidate="RadDatePicker2" ControlToCompare="RadDatePicker1" ErrorMessage="EndDate must be greater than StartDate" runat="server"></asp:CompareValidator>

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Shoaib
    Shoaib avatar
    9 posts
    Member since:
    Jul 2010

    Posted 11 Jan 2013 Link to this post

    Hi,

    I have a a radtree when I clicked on selected node so my panel [ panPro ] conditionally visible true. but If I am trying with this comparer code so it will not do anything .....????? waiting for your positive reply ..... I set type ="date" as well in comparer but it is not working .....



     <telerik:RadMultiPage ID="RadMultiPage2" runat="server" CssClass="multiPage">
     <telerik:RadPageView ID="RadPageView_EmployeeDetail" runat="server">
    <telerik:RadAjaxPanel runat="server" ID="panPro" Visible="false" >
    <table>
        <tr>
            <td>start date</td>
            <td><telerik:RadDatePicker ID="RadDatePicker1" MinDate="2009/1/1" runat="server" DateInput-Label="Start:">
            </telerik:RadDatePicker>
            <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator1" ControlToValidate="RadDatePicker1"
            ErrorMessage="Enter a date!"></asp:RequiredFieldValidator>
            </td>

        <td>end date</td>
        <td>
            <telerik:RadDatePicker ID="RadDatePicker2" MinDate="2009/1/1" runat="server" DateInput-Label="End:">
            </telerik:RadDatePicker>
            <asp:RequiredFieldValidator runat="server" ID="Requiredfieldvalidator2" ControlToValidate="Raddatepicker2"
            ErrorMessage="Enter a date!"></asp:RequiredFieldValidator>
            <br />
            <asp:CompareValidator ID="dateCompareValidator" runat="server" ControlToValidate="Raddatepicker2"
            ControlToCompare="RadDatePicker1" ErrorMessage="error" Display="Dynamic" Type="Date" >
            *</asp:CompareValidator>
            </td>
        </tr>
    </table>
     </telerik:RadAjaxPanel>
     </telerik:RadPageView>


    Regards
    Shoaib IQbal

                                                            


  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 15 Jan 2013 Link to this post

    Hi,

    Try the following code snippet to achieve your scenario.

    ASPX:
    <telerik:RadDatePicker ID="RadDatePicker1" MinDate="2009/1/1" runat="server" DateInput-Label="Start:">
    </telerik:RadDatePicker>
    <telerik:RadDatePicker ID="RadDatePicker2" MinDate="2009/1/1" runat="server" DateInput-Label="End:">
    </telerik:RadDatePicker>
    <asp:CompareValidator ID="dateCompareValidator" runat="server" ControlToValidate="Raddatepicker2" ControlToCompare="RadDatePicker1" ErrorMessage="error" Display="Dynamic" Type="Date" Operator="GreaterThan">*</asp:CompareValidator>

    Hope this helps.

    Regards,
    Princy.
  6. Shoaib
    Shoaib avatar
    9 posts
    Member since:
    Jul 2010

    Posted 16 Jan 2013 Link to this post

    I have a a radtree when I clicked on selected node so my panel [ panPro ] conditionally visible true.
    but If I am trying with this comparer code so it will not do anything .....?????
    waiting for your positive reply ..... I set type ="date" as well in comparer but it is not working .....
    after my multi page is postback it is working , do I need to add in script on page level ????


  7. Boity
    Boity avatar
    1 posts
    Member since:
    Apr 2016

    Posted 15 Apr in reply to Shinu Link to this post

    Thanks you for the post, it's working fine.

     

    Problem though is, everytime after I open the page, it locks my cancel button  unless I put in the fields it needs to compare. Now the problem is, what if the user doesn't want to proceed  entering records and just want to press cancel and continue with something else?

     

    Please advice as to how I can solve this issue

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