title: Javascript - date range validation
body: <p>i've a form user can enter any date , but i want to set a date range validation . for example: from 1-12-2012 to 1-1-2013 and the system can't accept any date from user that not in the range.. i've tried this javascript code but it doesn't give me any alert even when date not in range ..</p>
  
  <p>this is part of my form :</p>
  
  <pre><code> echo "&lt;tr&gt;&lt;th bgcolor='FF6600'&gt; Date &lt;font size='4' color='red'&gt;* &lt;/font&gt;&lt;/th&gt;
          &lt;td&gt; &lt;input type='date' name='v2' value=''   &gt;&lt;/td&gt;&lt;/tr&gt;";
  
  
  echo "&lt;tr&gt;&lt;th bgcolor='FF6600'&gt; Time &lt;font size='4' color='red'&gt;* &lt;/font&gt;&lt;/th&gt;
          &lt;td&gt; &lt;input type='time' name='v3' value=''   &gt;&lt;/td&gt;&lt;/tr&gt;";
  
          echo "&lt;tr&gt;&lt;th bgcolor='FF6600'&gt; Place &lt;font size='4' color='red'&gt;* &lt;/font&gt;&lt;/th&gt;
          &lt;td&gt; &lt;input type='text' name='v4' value=''   &gt;&lt;/td&gt;&lt;/tr&gt;";
  </code></pre>
  
  <p>and this is the javascript code </p>
  
  <pre><code>    &lt;script language="javascript"&gt;
  
      function validation(form)
   {
  
   var v2 = document.getElementById('v2');
   var date = v2.value;
   if ( (v2 &gt; new date('12/12/2012')) &amp;&amp; 
      (v2 &lt; new date('1/1/2013')) ){
      // date is in your valid range
       return true;
  } else {
      // date is not in your valid range
  
      alert("date is not in valid range")
      return false;
  }
  
  
  }
  
      &lt;/script&gt;
  </code></pre>