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;

parseDate(input) {
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.
parse_sDate parseDate(sDate);
parse_eDate parseDate(eDate);
parse_sDate.setDate(parse_sDate.setFullYear(parse_sDate.getMonth() + 12));
alert("End date should not be greater than one year from start date");
<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>
<input type="submit" value="Submit" onclick="test()">