codice:<html> <head> <script type="text/javascript" language="JavaScript"> <!-- function generateCategory( __hForm ) { var _bornDate = __hForm.elements["date"].value; var _dateToken = _bornDate.match( /^(\d{2})\/(\d{2})\/(\d{4})$/ ); if ( _dateToken == null || _dateToken[1] < 01 || _dateToken[1] > 31 || _dateToken[2] < 01 || _dateToken[2] > 12 || _dateToken[3] < 1900 || _dateToken[3] > 2005 ) { __hForm.elements["category"].options.length = 0; return false; } else { var _curDate = new Date( ); var _typDate = new Date( _dateToken[3], _dateToken[2]-1, _dateToken[1] ); var _gotAge = parseInt( (_curDate.getFullYear() + _curDate.getMonth() / 100 + _curDate.getDate() / 10000 ) - (_typDate.getFullYear() + _typDate.getMonth() / 100 + _typDate.getDate() / 10000 ) ); if ( _gotAge >= 18 && _gotAge <= 28 ) { with ( __hForm.elements["category"] ) { options.length = 0; options[options.length] = new Option( "Membro Junior", "junior", false, false ); options[options.length] = new Option( "Membro Super", "super", false, false ); } return true; } else if ( _gotAge >= 29 && _gotAge <= 40 ) { with ( __hForm.elements["category"] ) { options.length = 0; options[options.length] = new Option( "Membro Senior", "senior", false, false ); options[options.length] = new Option( "Membro Super", "super", false, false ); } return true; } else { with ( __hForm.elements["category"] ) { options.length = 0; options[options.length] = new Option( "Non puoi diventare membro", "invalid", false, false ); } return false; } } } //--> </script> </head> <body> <form> Data: <input type="text" name="date" value="gg/mm/aaaa" maxlength="10" onkeyup="generateCategory( this.form );" /> Categoria: <select name="category"></select> </form> </body> </html>