onkeyup小练习

<!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>

 

posted @ 2017-07-13 15:33  -CLAY-  阅读(170)  评论(0编辑  收藏  举报