Sunday 22 September 2013

Get difference between 2 dates in javascript and fromdate cannot be greater than todate?

 function ValidateDate()
        {
         var FrDateSelect =document.getElementById('<%=ddlfrDate.ClientID%>').value;
         var ToDateSelect =document.getElementById('<%=ddlToDate.ClientID%>').value;
         var diffDays = (new Date(ToDateSelect) - new Date(FrDateSelect))/ (1000 * 60 * 60 * 24* 30);
         if(new Date(ToDateSelect)<new Date(FrDateSelect))
         {
         alert('From Date Cannot be Greater than To Date');
         return false;
         }  
         else if(diffDays>4)
         {
         alert('select only range of any 3 months');
         return false;
         }  
         else
         {
         return true;
         }
         }

No comments:

Post a Comment

C# LINQ Joins With SQL

There are  Different Types of SQL Joins  which are used to query data from more than one database tables. In this article, you will learn a...