atessier
asked on
upperCase function using onKeyUp event handler
I am using the upperCase function using the onKeyUp event handler for a textbox on my html page. Here is an example of the code which does work: onKeyUp="javascript:this.v alue=this. value.toUp perCase(); "
The problem I'm having is that after you type in some letters and you want to go back to edit a letter. Using the backspace works fine and holding down the left arrow key will work but there is a limitation in using the left arrow key. I want to be able to press the left arrow key down once, twice, or as many times as I need but when I try this it takes me back to the end of the line (after all the characters I have typed in).
Does anyone know of anyway to get this to work and I don't want to use the onsubmit, onfocus, or onblur if I don't have to.
-Andrew
The problem I'm having is that after you type in some letters and you want to go back to edit a letter. Using the backspace works fine and holding down the left arrow key will work but there is a limitation in using the left arrow key. I want to be able to press the left arrow key down once, twice, or as many times as I need but when I try this it takes me back to the end of the line (after all the characters I have typed in).
Does anyone know of anyway to get this to work and I don't want to use the onsubmit, onfocus, or onblur if I don't have to.
-Andrew
Try putting "return true;" in it:
----------
onkeyup="javascript:this.v alue=this. value.toUp perCase(); return true;"
----------
returning true will let the browser do its thing ;-) .
----------
onkeyup="javascript:this.v
----------
returning true will let the browser do its thing ;-) .
ASKER
Adding the "return true;" did not work but thanks for the suggestion. I could use onchange but my intent was to have the upperCase take effect when the user type into the text box. I don't know if there is anything else that can be done for this or just settle for one of these other event handlers.
Please reply if you can help.
Please reply if you can help.
I am pretty certain that you will have to use the onChange() or onBlur().
Fritz the Blank
Fritz the Blank
Try using onkeypress instead, I'm almost certain that ignores everything except the alphanumeric keys.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Antithesis, what you have worked great. Being a beginner I can't understand very good though. The only problem I'm having with it is I have 3 textboxes on the same page. How can this work on each one with the code you gave me? Thanks, man!
for each of your text boxes, do it this way:
<input type="text" id="tbox" onkeypress="fixit('this.na me)">
Fritz the Blank
<input type="text" id="tbox" onkeypress="fixit('this.na
Fritz the Blank
Oops, that should be:
<input type="text" id="tbox" onkeypress="fixit(this.nam e)">
The idea is that this.name will pass the name of the textbox to the function.
Fritz the Blank
<input type="text" id="tbox" onkeypress="fixit(this.nam
The idea is that this.name will pass the name of the textbox to the function.
Fritz the Blank
Maybe you should use an attribute that actually exists :-P
----------
<input type="text" id="tbox1" onkeypress="fixit(this.id) ">
<input type="text" id="tbox2" onkeypress="fixit(this.id) ">
----------
Just make sure that all the textboxes have unique IDs. And thanks for the idea fritz, that's a much simpler way of going about it.
----------
<input type="text" id="tbox1" onkeypress="fixit(this.id)
<input type="text" id="tbox2" onkeypress="fixit(this.id)
----------
Just make sure that all the textboxes have unique IDs. And thanks for the idea fritz, that's a much simpler way of going about it.
I would recommend having name tags on all of your controls anyway.
Fritz the Blank
Fritz the Blank
ASKER
This answer along with one following comment solved my problem. I do appreciate it.
Here is the second part of the answer which resolves having multiple textboxes on the same page:
Maybe you should use an attribute that actually exists :-P
----------
<input type="text" id="tbox1" onkeypress="fixit(this.id) ">
<input type="text" id="tbox2" onkeypress="fixit(this.id) ">
----------
Just make sure that all the textboxes have unique IDs.
Here is the second part of the answer which resolves having multiple textboxes on the same page:
Maybe you should use an attribute that actually exists :-P
----------
<input type="text" id="tbox1" onkeypress="fixit(this.id)
<input type="text" id="tbox2" onkeypress="fixit(this.id)
----------
Just make sure that all the textboxes have unique IDs.
ASKER
Antithesis,
Thanks for your help. The only thing that is not working is when I hit the left arrow button to edit a character I have put in and when I press the key to add a character it takes me to the end of the line automatically. Any idea on how to solve this minor issue for editing.
-Andrew
Thanks for your help. The only thing that is not working is when I hit the left arrow button to edit a character I have put in and when I press the key to add a character it takes me to the end of the line automatically. Any idea on how to solve this minor issue for editing.
-Andrew
Fritz the Blank