Convert to uppercase as user types using javascript

后端 未结 12 1591
清酒与你
清酒与你 2020-12-13 17:59

I want to convert lowercase chars to uppercase as the user types using javascript. Any suggestions are welcome.

I have tried the following:

$(\"#text         


        
12条回答
  •  余生分开走
    2020-12-13 18:22

    $("#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());
    });
    

提交回复
热议问题