Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Uppercase conversion

Status
Not open for further replies.

aharrisreid

Programmer
Nov 17, 2000
312
GB

I have an input textbox on a form in which I want upper-case characters only, to which end I am using style="text-transform:uppercase" in the HTML input definition. Text is converted to upper-case upon data-entry, but the posted value is in the entered case, not always uppercase.
Using onchange="this.value=this.value.toUpperCase()" converts the entered string to uppercase, but only when the textbox loses focus.

What is the simplest way to ensure that entered data AND posted value are both uppercase? It seems rather clumsy to have to use both style and onchange commands for what should be a simple operation.

I would prefer a HTML/CSS solution if possible, but failing that, JavaScript will do.

TIA
Alan
 
The way you are doing it with teh onChange is about as dynamic as you will get this. there shouldn't be any reason why teh posted value is not upper case unless you are having problems with the inline function you have to change the value to upper case _______________________________________________
[sub]{ str = "sleep is good for you. sleep gives you the energy you need to function";
ptr = /sleep/gi;Nstr = str.replace(ptr,"coffee");alert(Nstr); }[/sub]
_______________________________________________
for the best results to your questions: FAQ333-2924
has you're questio
 
If you want it to change every time the field is entered, whether or not the value changes, you can change onChange to onBlur. Then, if the user changes the case on the field but not the value it will still update. Brian
 
If none of the above do what you expect them to, I would suggest using the OnKeyUp event to trigger the uppercase conversion.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top