Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to compare from date and to date using validator.

Posted on 2012-04-02
7
Medium Priority
?
310 Views
Last Modified: 2012-04-03
<td  class="td_style  report_color" style="width:auto">
            <div align="left">
                <asp:TextBox ID="txtfdate" runat="server" CssClass="report_color" Width="200px"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
                    ControlToValidate="txtfdate" ErrorMessage="*"></asp:RequiredFieldValidator>
            </div>
               
           </td>
           </tr>
           <tr>
            <td  class="td_style  report_color" style="width:auto">
            <div align="right">
                <asp:Label ID="Label2" runat="server" Text="Select To Date"></asp:Label>
                </div>
           </td>
           
            <td  class="td_style  report_color" style="width:auto">
            <div align="left">
                <asp:TextBox ID="txttdate" runat="server" CssClass="report_color" Width="200px"></asp:TextBox>
                <asp:CompareValidator ID="CompareValidator2" runat="server"
                    ControlToCompare="txtfdate" ControlToValidate="txttdate"
                    ErrorMessage="Should be more than From Date"></asp:CompareValidator>
            </div>
               
           </td>
0
Comment
Question by:searchsanjaysharma
  • 3
  • 2
  • 2
7 Comments
 
LVL 2

Expert Comment

by:Codecaesar
ID: 37795771
0
 

Author Comment

by:searchsanjaysharma
ID: 37795823
<td  class="td_style  report_color" style="width:auto">
            <div align="left">
                <asp:TextBox ID="txtfdate" runat="server" CssClass="report_color" Width="200px"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
                    ControlToValidate="txtfdate" ErrorMessage="*"></asp:RequiredFieldValidator>
            </div>
               
           </td>
           </tr>
           <tr>
            <td  class="td_style  report_color" style="width:auto">
            <div align="right">
                <asp:Label ID="Label2" runat="server" Text="Select To Date"></asp:Label>
                </div>
           </td>
           
            <td  class="td_style  report_color" style="width:auto">
            <div align="left">
                <asp:TextBox ID="txttdate" runat="server" CssClass="report_color" Width="200px"></asp:TextBox>
               <asp:CustomValidator ID="CustomValidator1"
 OnServerValidate="ValidateDuration" ControlToValidate="txttdate"
 
    ErrorMessage="Dates are too far apart" runat="server" />
   

Not working
0
 
LVL 15

Accepted Solution

by:
Navneet earned 2000 total points
ID: 37795996
Hi!
                <td class="td_style  report_color" style="width: auto">
                    <div align="left">
                        <asp:TextBox ID="txttdate" runat="server" CssClass="report_color" Width="200px"></asp:TextBox>
                        <asp:CompareValidator ID="CompareValidator2" runat="server" ControlToCompare="txtfdate"
                            ControlToValidate="txttdate" Operator="GreaterThan" Type="Date" ErrorMessage="Should be more than From Date"></asp:CompareValidator>
                    </div>
                </td>

Open in new window


Update this and try

Thanks!
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 15

Expert Comment

by:Navneet
ID: 37796003
only added
Operator="GreaterThan" Type="Date" 

Open in new window

check if this helps


Thanks!
0
 

Author Comment

by:searchsanjaysharma
ID: 37796019
How to empty the txttdate when validation occurs
0
 
LVL 2

Expert Comment

by:Codecaesar
ID: 37796186
<tr>
    <td  class="td_style  report_color" style="width:auto">
            <div align="left">
                <asp:TextBox ID="txtfdate" runat="server" CssClass="report_color" Width="200px"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
                    ControlToValidate="txtfdate" ErrorMessage="*"></asp:RequiredFieldValidator>
            </div>
               
     </td>
    </tr>
           <tr>
            <td  class="td_style  report_color" style="width:auto">
            <div align="right">
                <asp:Label ID="Label2" runat="server" Text="Select To Date"></asp:Label>
                </div>
           </td>
           </tr>
    <tr>
            <td  class="td_style  report_color" style="width:auto">
            <div align="left">
                <asp:TextBox ID="txttdate" runat="server" CssClass="report_color" Width="200px"></asp:TextBox>
                <asp:CompareValidator ID="CompareValidator2" runat="server"
                    ControlToCompare="txtfdate" ControlToValidate="txttdate"
                    ErrorMessage="Should be more than From Date"></asp:CompareValidator>
            </div>      
           </td>
        </tr>
Screen-1.jpg
screen-2.jpg
0
 

Author Closing Comment

by:searchsanjaysharma
ID: 37800441
ok
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question