在用户输入时使用JavaScript将文本转换为大写。

6 浏览
0 Comments

在用户输入时使用JavaScript将文本转换为大写。

我想使用JavaScript在用户输入时将小写字母转换为大写。欢迎任何建议。

我尝试了以下方法:

$("#textbox").live('keypress', function (e) {
    if (e.which >= 97 && e.which <= 122) {
        var newKey = e.which - 32;
        // 我尝试设置这些
        e.keyCode = newKey;
        e.charCode = newKey;
    }
});

0