soluzione funzionante:
codice:?php $giorno_adesso = date('d'); $mese_adesso = date('m'); $anno_adesso = date('Y'); ?> <script language="javascript"> function Validator(theForm){ var giorno=parseInt(theForm.GiornoNascita.value); var mese=parseInt(theForm.MeseNascita.value); var anno=parseInt(theForm.AnnoNascita.value); if((<?php echo $anno_adesso ?> - anno) > 18 ) { alert ("sei maggiorenne"); } else if ((<?php echo $anno_adesso ?> - anno) < 18 ) { alert ("sei minorenne"); } else if(((<?php echo $anno_adesso ?> - anno) == 18) && (<?php echo $mese_adesso ?> >= mese) && (<?php echo $giorno_adesso ?> >= giorno)) { alert ("sei maggiorenne"); } else { alert ("sei ancora minorenne"); } } </script> <form name="theForm" action="#" onsubmit="Validator(this)"> <input type="text" name="GiornoNascita" /> <input type="text" name="MeseNascita" /> <input type="text" name="AnnoNascita" /> <input type="submit" /> </form>

Rispondi quotando