$("#textbox").bind('keyup', function (e) {
if (e.which >= 97 && e.which <= 122) {
var newKey = e.which - 32;
// I have tried setting those
e.keyCode = newKey;
e.charCode = newKey;
}
$("#textbox").val(($("#textbox").val()).toUpperCase());
});
if (e.which >= 97 && e.which <= 122) {
var newKey = e.which - 32;
// I have tried setting those
e.keyCode = newKey;
e.charCode = newKey;
}
$("#textbox").val(($("#textbox").val()).toUpperCase());
});
本文介绍了一种使用JavaScript的方法,实现在用户输入文本时将小写字母自动转换为大写字母的功能。通过监听键盘事件并修改字符编码,确保所有输入的字母都以大写形式呈现。
118

被折叠的 条评论
为什么被折叠?



