così è ancora più corretto...funhzionante ed arricchito di tutti i controlli possibili ed immaginabili....

Codice PHP:
<html>
<
head>
<
title></title>
<
script>
function 
CalcoloEta() {
var 
oggi=new Date();
var 
annocorrente=oggi.getFullYear();
var 
mesecorrente=oggi.getMonth()+1;

var 
annonascita=Number(document.myForm.anno.value);
var 
mesenascita=Number(document.myForm.mese.value);

if(
isNaN(annonascita)){
   
alert("Anno non numerico!");
}

else if(
annonascita>annocorrente){
   
alert("Anno superiore a quello attuale!");
}

else if((
annonascita==annocorrente)&&(mesenascita>mesecorrente)){
      
alert("Data superiore a quella attuale!");
   }

else if(
isNaN(mesenascita)){
   
alert("Mese non numerico!");
}

else if((
mesenascita<1)||(mesenascita>12)){
   
alert("I mesi vanno da 1 a 12!");
}

else{

var 
totAnni=annocorrente-annonascita;
var 
totMesi=mesecorrente-mesenascita;

if(
totMesi<0){
   
totAnni--;
   
totMesi=12-(totMesi*-1);
}
alert("Hai esattamente "+(totAnni)+" anni e "+(totMesi)+" mesi.")
}
}
</script>
</head>
<body>
<form name="myForm">


Anno Nascita: <input type="text" name="anno"></p>


Mese Nascita: <input type="text" name="mese"></p>
<input type="button" value="anni" onclick="CalcoloEta()">
</form>
</body>
</html>