I want to convert lowercase chars to uppercase as the user types using javascript. Any suggestions are welcome.
I have tried the following:
$("#textbox").live('keypress', 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; } });
Advertisement
Answer
$("#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()); });