?
Solved

How to compare from date and to date using validator.

Posted on 2012-04-02
7
Medium Priority
?
308 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 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
Industry Leaders: 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

719 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