Help on Javascript and html needed

Status
Not open for further replies.

Kalyan

Journeyman
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

I see right through you.
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

हॉर्न ओके प्लीज़
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.
 
OP
Kalyan

Kalyan

Journeyman
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..
 
Status
Not open for further replies.
Top Bottom