Hi, this script work im Crhome, but not in IE, or Firefox, please help me!!

<!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=iso-8859-1" />
<title>teste</title>
<script>
function idade(object, birthDay){
      now = new Date();
      bD = birthDay.value.split('/');
      if(bD.length==3){
              born = new Date(bD[2], bD[1]*1-1, bD[0]);
            years = new Date(now.getTime() - born.getTime());
            base = new Date(0);
            document.all['AGE'].value = years.getFullYear()-base.getFullYear();
      }
}
</script>
</head>


<body>
<form action="" method="post" name="form">
<table>
<tr>
<td>
<input name="datanascimento" type="text" style="width:100%" onChange="idade(this.form, this);"/>
<input name="AGE" type="text" style="width:100%">
</td>
</tr>
</table>
</form>
</body>
</html>
<!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=iso-8859-1" />
<title>teste</title>
<script>
function idade(object, birthDay){
	var now = new Date();
	bD = birthDay.value.split('/');
	if(bD.length==3){
		var born = new Date(bD[2], bD[1]*1-1, bD[0]);
		document.getElementById("computedAge").value = ( now.getFullYear() - born.getFullYear() )
	}
}
</script>
</head>


<body>
<form action="" method="post" name="form">
	<table summary="" style="width:10%">
		<tbody>
			<tr>
				<td>
					<input name="datanascimento" type="text" style="display:block;width:100%" onchange="idade(this.form, this);"/>
					<input id="computedAge" name="AGE" type="text" style="display:block;width:100%" readonly="readonly">
				</td>
			</tr>
		</tbody>
	</table>
</form>
</body>
</html>

worked perfect, thank you.
only one problem, I do birthday November 11, was born in 1987, I have not done 23 years, but it gives me message that I have 23 years ... do not know if you understood, would give me 22 years because I have not done 23 years yet.

Thank you.

function idade(object, birthDay){
	var now = new Date();
	bD = birthDay.value.split('/');
	if(bD.length==3){
		var born = new Date(bD[2], bD[1]*1-1, bD[0]);
		var age=now.getFullYear() - born.getFullYear();
		var yearBD = new Date(now.getFullYear(), bD[1]*1-1, bD[0]);
		if( now.valueOf() < yearBD.valueOf()  )
			--age;
		document.getElementById("computedAge").value = age;
	}
}

100%, it worked exactly as I wanted. excuse is that I'm new
still in javascript....

thank you so much!!

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.