Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
comparision of two textboxes using Dates ... Calendar Extender in Asp.net
=============================================================================

Hello Friends,

am working on ASP.Net Project using C# SqlServer 2005 DB.

on my webpage I have two Textboxes with Calendar Extender with it.

1st Textbox - Issued Date (TxtIssuedDate)
2nd Textbox - Expiry Date (TxtExpiryDate)

Now i want to Compare the two textboxes. If i select Date from Issued Date , AND NEXT
when i Select Expiry date the expiry date must be greater than Issued Date and Todays Date.

so please help me, how to do this.

Thanks in @dvance.
Posted

validate at the time of submit wheather issue date is greater or not,
C#
bool validate()
{
if (Datetime.Parse(TxtIssuedDate.text) > Datetime.Parse(TxtExpiryDate.text))
        {
            return false;
        }
else
{
return true;
}
}
 
Share this answer
 
v2
Hi,
You can use this javascript
JavaScript
function CheckValid() {

          var fromDate = $('#<%=txtFromDt.ClientID %>').val();
          var toDate = $('#<%= txtTodt.ClientID %>').val();
          if ((fromDate != "" && toDate != "") && Date.parse(fromDate) > Date.parse(toDate)) {
              // alert("To date should be greater than From date.");
              $('#<%= lblErrorMsg.ClientID %>').text('To date should be greater than From date.');
              return false;
          }
      }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900