用户名:<input type="text" name="username" id="username"><br /> 密码:<input type="text" name="password" id="password"> <input type="submit" value="注册"> <script type="text/javascript"> var username=document.getElementById("username"); username.addEventListener("keyup",fl); function fl(evt){ alert(evt.keyCode); document.getElementById("password").value+=evt.keyCode+"."; } </script>