<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>输入验证码大写</title> </head> <body> <form action=""> <p>name:</p> <p><input type="text"></p> <p>密码:</p> <p><input type="text"></p> <p>验证码</p> <p><input type="text" id="verify"></p> <p><input type="submit" value="ok"></p> </form> <script> var verify = document.getElementById("verify"); verify.onkeyup = function(){ var val = this.value; var val1 = val.toUpperCase(); this.value = val1; }; </script> </body> </html>