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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to type uppercase

Status
Not open for further replies.

request

Programmer
Dec 5, 2001
76
US
I have text boxes on a form. When the user types in those text boxes, the values should be displayed in the uppercase. How do I do it?

Please help.
 
Javascript would more than likely be the most cross-browser compatible way. Assign a javascript function to the onKeyPress event of the text field that takes the content of the field and replaces it with the uppercased version.
But there will always be a slightly disconcerting "flash" as the user types.

To avoid the flash, you can do it with CSS, as well... with something like:
Code:
<style>
.captext{
	text-transform : uppercase;
}
</style>

   :

<form ...>
	<input type=&quot;text&quot; name=&quot;name&quot; class=&quot;captext&quot;>
</form>
by this won't be as cross-browser compatible. So depending on whether it's an intranet app where you might have greater control over what browsers are hitting the page, or an internet app where it's being hit by everything under the sun, that'll kind of decide for you which solution you use.



-Carl
 
Of course... the other option is to simply let the user type the value in whatever case they want, and then you capitalize it when it comes time to store it in the database or whatever you're doing with it.

Like:
formpage.cfm-
Code:
<form action=&quot;okpage.cfm&quot; method=&quot;POST&quot; ...>
    <input type=&quot;text&quot; name=&quot;firstname&quot;>
</form>
and
okpage.cfm-
Code:
   <CFQUERY ...>
      INSERT INTO myTable
      (firstname) VALUES ('#UCase(FORM.firstname)#')
   </CFQUERY>
then it wouldn't matter whether the user typed their first name in upper case, lower case, or mixed case... it would still get stored in all upper case.



-Carl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top