Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert to uppercase as user types using javascript

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;     } }); 
like image 526
Butcher Avatar asked Apr 06 '11 18:04

Butcher


People also ask

How do you change to uppercase in JavaScript?

JavaScript String toUpperCase()The toUpperCase() method converts a string to uppercase letters. The toUpperCase() method does not change the original string.

Which function use in JavaScript convert uppercase into lowercase character?

JavaScript String toLowerCase() The toLowerCase() method converts a string to lowercase letters. The toLowerCase() method does not change the original string.

What does toUpperCase mean in JavaScript?

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.

How do you make uppercase in HTML?

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> .


1 Answers

css  #textbox{text-transform:uppercase} 
like image 58
kennebec Avatar answered Sep 20 '22 20:09

kennebec