DIGIT-ARC read-only archive · snapshot: July 23, 2026

Help on Javascript and html needed

4 posts · originally from https://geek.digit.in/community/threads/help-on-javascript-and-html-needed.72243/

K
Kalyan Original post #1
Nov 2, 2007 at 1:31 PM
Hi all..
I have a textbox in my page which should automatically convert the keyed-in text to upper-case. I previously did it through conversion on keypress event through javascript. But when I made any typing mistake and want to edit it, the left arrow is not allowing me to go back. Instead, I have to use backspace, undo the text and then retype the correct one.

I also tried the style="text-transform:uppercase" in the <input type="text" id="myTxtBox"... and the text dynamically converts to uppercase. But, when I retrieve the text from the textbox through document.getElementById("myTxtBox").value, I still get the lowercase letters. Is there any method to retrieve the transformed text from the textbox through javascript? Please help..... Thanks a lot
Sykora
Sykora #2
Nov 2, 2007 at 4:08 PM
I think the trick is to do both (ie style as well as the js) :

Code:
<input type="text" name="realbig" style="text-transform:uppercase;" on keyup="javascript:this.value=this.value.toUpperCase();">

Is it necessary that the text shows as uppercase on screen? If not, then you can just as well retrieve the text as lowercase, and convert them using the string.toUpperCase() method.
victor_rambo
Nov 4, 2007 at 1:21 PM
Where do you retrieve that value?

If its in another text-box or text-area, you can try to set its style attribute to 'Uppercase' too.
K
Kalyan #4
Nov 5, 2007 at 12:20 PM
Thanks guyz.. googled on the net for this problem, found some answers. I finally decided to have the .toUpperCase() on onBlur="" event. That solves my problem. I couldnt find a better solution for this.

Where do you retrieve that value?

If its in another text-box or text-area, you can try to set its style attribute to 'Uppercase' too.

I need that from the current textbox, in which the user is typing.

Doing both the style thing and onKeyUp="" thing wouldnt solve my problem either. since, doing both doesnt make any difference.

Anyways, thanks for your replies..