how to compare the date entered in textbox to the current date using javascript?
<p>How can I check that the date entered in a textbox is less than today's date using java script?</p>

<p>I m using code </p>

<pre><code>var currentDate_Month = new Date().valueOf().getMonth();
        var currentDate_Date = new Date().getDate();
        var currentDate_Year = new Date().getFullYear();
        var EnterDate_Month = new Date(document.getElementById('ctl00_ContentPlaceHolder1_txtDateReceived').value).getMonth();
        var EnterDate_Date = new Date(document.getElementById('ctl00_ContentPlaceHolder1_txtDateReceived').value).getDate();
        var EnterDate_Year = new Date(document.getElementById('ctl00_ContentPlaceHolder1_txtDateReceived').value).getFullYear();

        if(EnterDate_Year&lt;currentDate_Year) {
          if(EnterDate_Month&lt;currentDate_Month) {
            if(EnterDate_Date&lt;currentDate_Date) {
            }
           }
          }
         else {   
            str += '&lt;/br&gt;* Date should be Less than or equals to current Date.';
            return false;
         }
</code></pre>

<p>But to my surprise the current date coming in the textbox control is Sat Jun 7 2014 when viewing it by -</p>

<pre><code>new Date(document.getElementById('ctl00_ContentPlaceHolder1_txtDateReceived').value).toDateString();
</code></pre>

<p>Why is it returning the date in this format? (the date in text box is in format dd/mm/yyyy)</p>

<p>thanks in advance.</p>
