IndyB
06-11-2003, 11:39 AM
I've got the following script which gets the user's birth date (Bdate_1) from a form, and computes the user's age. I need to add functionality to this script that also makes sure the user is greater than or equal to 14 days old. Anyone know how I might do that?
function checkBirthDate()
{
var today = new Date();
var bDate = new Date(document.frmpage.Bdate_1.value);
var minAge = document.frmpage.min_age_1.value;
var maxAge = document.frmpage.max_age_1.value;
var thisAge = ((today - bDate) / 1000 / 60 / 60 / 24 / 365.25);
if(minAge <= thisAge && thisAge <= maxAge)
{ }
else
{
alert("Your age is not between " + minAge + " and " + maxAge + ".");
frmpage.Bdate_1.value = "";
frmpage.Bdate_1.focus();
}
}
function checkBirthDate()
{
var today = new Date();
var bDate = new Date(document.frmpage.Bdate_1.value);
var minAge = document.frmpage.min_age_1.value;
var maxAge = document.frmpage.max_age_1.value;
var thisAge = ((today - bDate) / 1000 / 60 / 60 / 24 / 365.25);
if(minAge <= thisAge && thisAge <= maxAge)
{ }
else
{
alert("Your age is not between " + minAge + " and " + maxAge + ".");
frmpage.Bdate_1.value = "";
frmpage.Bdate_1.focus();
}
}