I am trying to validate date based on date entered in first textbox. If second textbox exceeds one year from the date entered in first textbox, then it should display an alert and blank the second date field textbox. Both the textboxes are readonly and gets the values from calender. I tried the below code and it is not validating if second textbox value is greater than one year. Any help !

PHP Code:
  function test()
  {
      
start document.getElementById('name3').value;
      
end document.getElementById('name4').value;
      
compare(startend);
      
  }

  function 
compare(sDateeDate)
  {
      
      function 
parseDate(input) {
            var 
parts input.match(/(\d+)/g);
             
            return new 
Date(parts[2], parts[0]-1parts[1]); // months are 0-based. Parts2 contains year, parts0 contains month and parts1 contains date.
          
}
       var 
parse_sDate parseDate(sDate);
      var 
parse_eDate parseDate(eDate);
      
parse_sDate.setDate(parse_sDate.setFullYear(parse_sDate.getMonth() + 12));
      if(
parse_sDate>parse_eDate)
          {
          
alert("End date should not be greater than one year from start date");
          }
       
  }
  
</script>
</head>
<body>
<form>
<table>
<tr>
<td><input type="text" name="soname3" id="name3" size="15" readonly="readonly"> 
<img src="../Image/cal.gif" id="" style="cursor: pointer;" onclick="javascript:NewCssCal('name3','MMddyyyy','dropdown',false,'12')" /></td>
 <td><input type="text" name="soname4" id="name4" size="15" readonly="readonly">
 <img src="../Image/cal.gif" id="" style="cursor: pointer;" onclick="javascript:NewCssCal('name4','MMddyyyy','dropdown',false,'12'); " /> </td>
 </tr>
</table>
<input type="submit" value="Submit" onclick="test()">
</form>