Solved

How to compare from date and to date using validator.

Posted on 2012-04-02
7
306 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

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!

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

627 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