I have the below code:
function CheckDOB(DOB)
{
var d = new Date();
var curr_date = d.getDate();
var curr_month = d.getMonth();
var curr_year = d.getFullYear();
var dobDate = new Date(DOB);
var dobDay = dobDate.getDate();
var dobMonth = dobDate.getMonth();
var dobYear = dobDate.getFullYear()
DOB = new Date(dobDay, dobMonth, dobYear );
console.log("DOB: " + DOB);
var today = Date(curr_date, curr_month, curr_year);
console.log("Today: "+ today);
if (DOB >= today)
{
console.log("in false");
alert("Date of Birth cannot be greater than today.");
alert = function(){};
return false;
}
else
{
console.log("in true");
return true;
}
}
function txtCompPersonDOB_OnChange()
{
var DOB = CSForm.getField('txtCompPersonDOB').getValue();
//console.log(DOB);
if(CheckDOB(DOB))
{
console.log("test on change: false")
CSForm.getField('txtCompPersonDOB').setFocus();
}
else
{
console.log("test on changeL true");
}
}
I am using an old version of LiquidOffice, which allows you to create eForms using JavaScript.
The date is getting picked bu a Date Picker (in string format) and then I am converting it to date using the CheckDOB()
function.
These are the console.log()
results:
For some reason the dates are not appearing correctly and the comparison is off. the DOB picked is 27/01/2018
but in the console logged it is shown as 10/09/1906
Can anyone tell me what I am missing or doing wrong from my end?
The alerts don't get triggered for some reason, and the date does not match that of the selection.