I am trying to use gen_validatorv4.js script to compare two dates in a form. I am new to javascript and I am having difficulty making this work properly.
It works when the End Date is greater than the Start date in the same month, however, as soon as I try and compare dates in different months i.e. Start Date 30/11/2013 and End Date of 05/12/2013 I get the error saying the “Leave End Date must be equal to or greater than the Leave Start Date”. For some reason the script seems to be comparing the day portion of the date and nothing else.
Here is the script that I am using -
function DoCustomValidation() {
var frm = document.forms["otherleave"];
var StartDate = new Date(frm.LeaveStartDate.value);
var EndDate = new Date(frm.LeaveEndDate.value);
if (StartDate > EndDate){
sfm_show_error_msg('Leave End Date must be equal to or greater than Leave Start Date.',frm.LeaveEndDate);
return false;
return true;

This is only the custom portion of the script. The rest is working like a gem.

Any help from javascript jedi’s out there would be appreciated!