title: Start date must be earlier than end date
body: <p>I am comparing some dropdownlist value, basically the Start date must be earlier than end date 
  <br/><br/>I found a lot of sample source codes through goggle and others, but they only provide DD/MM/YYYY. <br/> I only need MM/YYY only, when ever i tried to remove "DD" there would be errors, if i am right its because of the date keyword/element. </p>
  
  <p>Is there any solution to it? any help or ref link would be good. Thanks </p>
  
  <p>P.s The codes below are working for DD/MM/YYYY</p>
  
  <p>
    
  
  <pre><code>function y2k(number) {
      return (number &lt; 1000) ? number + 1900 : number;
  }
   function padout(number) {
      return (number &lt; 10) ? '0' + number : number;
  }
  
  function validate(what) {
      var startday = what.startday.options[what.startday.selectedIndex].value;
      var startmonth = what.startmonth.options[what.startmonth.selectedIndex].value;
      var startyear = what.startyear.options[what.startyear.selectedIndex].text;
      var endday = what.endday.options[what.endday.selectedIndex].value;
      var endmonth = what.endmonth.options[what.endmonth.selectedIndex].value;
  
      unvalidstartdate = startday + '/' + startmonth + '/' + startyear;
      unvalidenddate = endday + '/' + endmonth;
  
      var startdate = new Date(startyear - 0, startmonth - 1, startday - 0);
      var enddate = new Date(endmonth - 1, endday - 0);
  
      var validstartdate = padout(startdate.getDate()) + '/'
              + padout(startdate.getMonth() + 1) + '/'
              + y2k(startdate.getYear())
      var validenddate = padout(enddate.getDate()) + '/'
              + padout(enddate.getMonth() + 1) + '/' + y2k(enddate.getYear());
  
      if (unvalidstartdate != validstartdate) {
          alert('Start Date: '
                  + what.startday.options[what.startday.selectedIndex].text
                  + ' '
                  + what.startmonth.options[what.startmonth.selectedIndex].text
                  + ' '
                  + what.startyear.options[what.startyear.selectedIndex].text
                  + ' is invalid');
          return false;
      }
  
      if (unvalidenddate != validenddate) {
          alert('End Date: '
                  + what.endday.options[what.endday.selectedIndex].text + ' '
                  + what.endmonth.options[what.endmonth.selectedIndex].text
                  + ' '
  
                  + ' is invalid');
          return false;
      }
  
      starttime = Date.UTC(y2k(startdate.getYear()), startdate.getMonth(),
              startdate.getDate(), 0, 0, 0);
      endtime = Date.UTC(y2k(enddate.getYear()), enddate.getMonth(), enddate
              .getDate(), 0, 0, 0);
  
      if (starttime &lt; endtime) {
      alert('VALID');         
              // valid
          } else {
              alert('NOT VALID');
              return false;
      }
  
      currentdate = new Date();
      currenttime = Date.UTC(y2k(currentdate.getYear()), currentdate
              .getMonth(), currentdate.getDate(), 0, 0, 0);
  
      if (endtime &lt; currenttime) {
          // valid
      } else {
          alert('End Date is not less than todays date');
          return false;
      }
  
      what.startdate.value = validstartdate;
      what.enddate.value = validenddate;
      return true;
  }
   //--&gt;
    &lt;/script&gt;
  
   &lt;form&gt;
  Start Date: &lt;select name="startday"&gt;
      &lt;option value="01"&gt;1st
      &lt;option value="02"&gt;2nd
      &lt;option value="03"&gt;3rd
  
  &lt;/select&gt; &lt;select name="startmonth"&gt;
      &lt;option value="01"&gt;january
      &lt;option value="02"&gt;february
      &lt;option value="03"&gt;march
  
  &lt;/select&gt; &lt;select name="startyear"&gt;
      &lt;option&gt;1990
      &lt;option&gt;1991
      &lt;option&gt;1992
  &lt;/select&gt;
  
  &lt;p&gt;
  
      End Date: &lt;select name="endday"&gt;
          &lt;option value="01"&gt;1st
          &lt;option value="02"&gt;2nd
          &lt;option value="03"&gt;3rd
  
      &lt;/select&gt; &lt;select name="endmonth"&gt;
          &lt;option value="01"&gt;january
          &lt;option value="02"&gt;february
          &lt;option value="03"&gt;march
  
      &lt;/select&gt;  &lt;input type="hidden" name="startdate"&gt; &lt;input type="hidden"
          name="enddate"&gt;
     &lt;p&gt;
  
      &lt;input type="button" onClick="validate(this.form)" value="Validate"&gt;
  &lt;/form&gt;
  </code></pre>