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

Comparing two raddatepicker

5 Answers 359 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Balaji
Top achievements
Rank 1
Balaji asked on 25 Aug 2011, 09:39 PM
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

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 26 Aug 2011, 05:37 AM
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.
0
Shoaib
Top achievements
Rank 1
answered on 11 Jan 2013, 01:21 PM
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

                                                        


0
Princy
Top achievements
Rank 2
answered on 15 Jan 2013, 09:50 AM
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.
0
Shoaib
Top achievements
Rank 1
answered on 16 Jan 2013, 11:10 AM
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 ????


0
Boity
Top achievements
Rank 1
answered on 15 Apr 2016, 11:24 AM

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

Tags
General Discussions
Asked by
Balaji
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Shoaib
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Boity
Top achievements
Rank 1
Share this question
or