hi, I've got a problem and i really need help.
this is my code

<script>
var y= new Date();
y.getFullYear() + '<br />';
alert(y);
var year = new Date();
year.setFullYear(prompt('Enter the year','1990'),prompt('Enter the month','1'), prompt('Enter the day','1'));
alert(year);
var yy = y-year;
alert(yy);
</script>

i want when a user write his/her birthday JS calculate the age. that's all

function getAge(dateString) {
    var today = new Date();
    var birthDate = new Date(dateString);
    var age = today.getFullYear() - birthDate.getFullYear();
    var m = today.getMonth() - birthDate.getMonth();
    if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) {
        age--;
    }
    return age;
}

alert(getAge("09/23/1981"));

This is from: http://stackoverflow.com/questions/4060004/calculate-age-in-javascript

Simply pass the getAge function the users birthday and whala!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.