title: javascript date validation - checking two dates
body: <p>i have two input box for getting date value in the format "dd/mm/yyyy". </p>
  
  <p>i have to create coupon for a shop, so i have to check 1st date should be from tomorrow. 
  for ex. if today is 5th sep, then 1st date should not be before 6th sep.</p>
  
  <p>and 2nd date should be atleast 1day greater than the 1st date. if user entered 1st date as 10th sep, then 2nd date should not be same or before 10th sep. </p>
  
  <p>so if a user enters 31st jan 2013 ( 31/01/2013) as 1st date then 2nd date can be 1st feb or any date after 1st feb. so i hvae to check the date validation also. 
   for date validation i am using the following code - </p>
  
  <pre><code>    function chkdate(y,m,d)
      {
          var date = new Date(y,m-1,d);
          month1 = date.getMonth()+1;
          date1  =date.getDate();
          if(month1 &lt;10)
                { 
                 month1 = "0"+month1;
                }
          if(date1 &lt;10)
                { 
                 date1 = "0"+date1;
                }
          var convertedDate =""+date.getFullYear() + (month1) + date1;
          var givenDate = "" + y + m + d;
          return ((givenDate==convertedDate)?true:false); 
       }  
  </code></pre>
  
  <p>i am callling above function inside a function -</p>
  
  <pre><code>  function generate_coupon()
    {
           var f_arr = from_date.split("/"); //from_date is from 1st input date value.
       var f_day = f_arr[0];
       var f_month =f_arr[1];
       var f_year =f_arr[2]; 
  
           var t_arr = to_date.split("/"); //to_date is from 2nd input date value.
       var t_day = t_arr[0];
       var t_month =t_arr[1];
       var t_year =t_arr[2]; 
  
           if (chkdate(f_year,f_month,f_day)== true &amp;&amp; chkdate(t_year,t_month,t_day)== true)
           {
  
           }
          else
           {
            alert('Enter Valid Date - dd/mm/yyyy');
           }
      }
  </code></pre>
  
  <p>in that if condition i have to check both date values - the 1st date value is from tomorrow or not  and  2nd date value should differ from 1st date by atleast 1 day. if both conditions are true then i wil generate a coupon or else i will alert invalid date. </p>
  
  <p>how should i do it ?? </p>