Solved

How to compare from date and to date using validator.

Posted on 2012-04-02
7
299 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:
navneethegde 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 15

Expert Comment

by:navneethegde
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
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!
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now