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; } });
JavaScript String toUpperCase()The toUpperCase() method converts a string to uppercase letters. The toUpperCase() method does not change the original string.
JavaScript String toLowerCase() The toLowerCase() method converts a string to lowercase letters. The toLowerCase() method does not change the original string.
The toUpperCase() method returns the value of the string converted to uppercase. This method does not affect the value of the string itself since JavaScript strings are immutable.
Step 1: wrap the words or lines you want to be on uppercase inside tag. Ex. <span> This line will be in uppercase </span> . Step2: Ass css on to the span tag as shown here <span style="text-transform:uppercase;"> This line will be in uppercase </span> .
css #textbox{text-transform:uppercase}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With