<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script>
function getAge(dateString) {
var today = new Date();
var birthDate = new Date(dateString);
var age = today.getFullYear() - birthDate.getFullYear();
if(age !="")
{
document.getElementById('age').value = age;
}
}
</script>
</head>
<body>
input birthdate :<input type="text" id="birthday" value="" onkeydown="if(this.value !='' && this.value.length==10 && event.keyCode==13){getAge(this.value);}"> enter to calculate<br>
current your age :<input type="text" id="age" readonly="readonly"> years
</body>
</html>