This involves a couple of functions, so it makes it difficult to explain, I have a function that needs two different dates to work that is the alert#1 below needs to validate on the year exactly, that 1941 + today and 2002 + today. alert # 5 needs 1941 + today and 2002 + today -this gives the date plus one as I will try to show below
globals=
RegularMember = true;
RetirementAge = 60;
trying to a flag - hurrah = false;
function calcAge(frm)
{
var ageAtTerm;
var birthYr;
var birthMn;
var birthDy;
var termYr;
var termMn;
var termDy;
with (frm)
{
birthYr = birthDateYear.options[birthDateYear.selectedIndex].value;
birthMn = birthDateMonth.options[birthDateMonth.selectedIndex].value;
birthDy = birthDateDay.options[birthDateDay.selectedIndex].value;
termYr = termDtYear.options[termDtYear.selectedIndex].value;
termMn = termDtMonth.options[termDtMonth.selectedIndex].value;
termDy = termDtDay.options[termDtDay.selectedIndex].value;
} //end with
bDate = new Date(birthYr,birthMn-1,birthDy,0,0,0);
tDate = new Date(termYr,termMn-1,termDy,0,0,0);
bDateYear=bDate.getYear();
if (bDateYear<1900) bDateYear+=1900;
tDateYear=tDate.getYear();
if (tDateYear<1900) tDateYear+=1900;
ageAtTerm = tDateYear-bDateYear;
if (bDate.getMonth()>tDate.getMonth() ||
(bDate.getMonth()==tDate.getMonth() && bDate.getDate() >= tDate.getDate()) )
ageAtTerm--;
alert(ageAtTerm + " (calcAge years)"
;
return ageAtTerm;
}
---------------------------------------------
some places the the validation needs:
#1 alert needs
(bDate.getMonth()==tDate.getMonth() && bDate.getDate() > tDate.getDate()) )
# 4 needs:
(bDate.getMonth()==tDate.getMonth() && bDate.getDate() >= tDate.getDate()) )
>
or
>=
// alert # 1 = bd
//need this > tDate.getDate()) )
if ( RegularMember &&
(RCMP_Pensionable_Years < 10) &&
(DischargeMethod == "1"
&&
//(CurrentAge >= RetirementAge) &&hurrah)
(CurrentAge >= RetirementAge) )
// validation # 5 = bd+1
//======= If age > 60 adjust termination date=======//
if ( RegularMember &&
(CurrentAgeA >= RetirementAge) )
====================
also needs this
function isValidAge(frm) {
if ((CurrentAge=calcAge(frm)) < 19)
use the flag here
if (bDate.getMonth()==tDate.getMonth() && bDate.getDate() == tDate.getDate()) hurrah=true;
if (bDate.getMonth()>tDate.getMonth() ||
(bDate.getMonth()==tDate.getMonth() && bDate.getDate() >= tDate.getDate()) )
ageAtTerm--;
then when you need to you can change
(CurrentAge >= RetirementAge) ) {
to
(CurrentAge >= RetirementAge) &&!hurrah)
globals=
RegularMember = true;
RetirementAge = 60;
trying to a flag - hurrah = false;
function calcAge(frm)
{
var ageAtTerm;
var birthYr;
var birthMn;
var birthDy;
var termYr;
var termMn;
var termDy;
with (frm)
{
birthYr = birthDateYear.options[birthDateYear.selectedIndex].value;
birthMn = birthDateMonth.options[birthDateMonth.selectedIndex].value;
birthDy = birthDateDay.options[birthDateDay.selectedIndex].value;
termYr = termDtYear.options[termDtYear.selectedIndex].value;
termMn = termDtMonth.options[termDtMonth.selectedIndex].value;
termDy = termDtDay.options[termDtDay.selectedIndex].value;
} //end with
bDate = new Date(birthYr,birthMn-1,birthDy,0,0,0);
tDate = new Date(termYr,termMn-1,termDy,0,0,0);
bDateYear=bDate.getYear();
if (bDateYear<1900) bDateYear+=1900;
tDateYear=tDate.getYear();
if (tDateYear<1900) tDateYear+=1900;
ageAtTerm = tDateYear-bDateYear;
if (bDate.getMonth()>tDate.getMonth() ||
(bDate.getMonth()==tDate.getMonth() && bDate.getDate() >= tDate.getDate()) )
ageAtTerm--;
alert(ageAtTerm + " (calcAge years)"
return ageAtTerm;
}
---------------------------------------------
some places the the validation needs:
#1 alert needs
(bDate.getMonth()==tDate.getMonth() && bDate.getDate() > tDate.getDate()) )
# 4 needs:
(bDate.getMonth()==tDate.getMonth() && bDate.getDate() >= tDate.getDate()) )
>
or
>=
// alert # 1 = bd
//need this > tDate.getDate()) )
if ( RegularMember &&
(RCMP_Pensionable_Years < 10) &&
(DischargeMethod == "1"
//(CurrentAge >= RetirementAge) &&hurrah)
(CurrentAge >= RetirementAge) )
// validation # 5 = bd+1
//======= If age > 60 adjust termination date=======//
if ( RegularMember &&
(CurrentAgeA >= RetirementAge) )
====================
also needs this
function isValidAge(frm) {
if ((CurrentAge=calcAge(frm)) < 19)
use the flag here
if (bDate.getMonth()==tDate.getMonth() && bDate.getDate() == tDate.getDate()) hurrah=true;
if (bDate.getMonth()>tDate.getMonth() ||
(bDate.getMonth()==tDate.getMonth() && bDate.getDate() >= tDate.getDate()) )
ageAtTerm--;
then when you need to you can change
(CurrentAge >= RetirementAge) ) {
to
(CurrentAge >= RetirementAge) &&!hurrah)