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!

Change all text to uppercase in a text field 2

Status
Not open for further replies.

optjco

IS-IT--Management
Apr 13, 2004
185
GB
Hi,
can someone help me I have a submit form that contains one text field where the user will input the name of a customer. I would like all the letters to be converted to uppercase irrespective of how the data is entered. I tried
Code:
,input name="txtCust" type="text" id="txtCust" onKeyUp = "toUpperCase" size="18" maxlength="15"
But that does not seem to work

Regards

Olly
 
if you want to use javascript the code would be

Code:
onchange="javascript:this.value=this.value.toUpperCase

or using ASP (vbScript) as this is the aformentioned forum
Code:
variable = ucase(request.form("inputname"))



Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
Chris,
Could you explain where to put either of these pieces of code. I do not seem to be able to get either one working

Regards

Olly
 
Hello optjco,

Another method is to use inline style.

[tt]<input name="txtCust" type="text" [blue]style="text-transform: uppercase"[/blue] id="txtCust" onKeyUp = "toUpperCase" size="18" maxlength="15">[/tt]

until whatever toUpperCase you eventually decide to script.

regards - tsuji
 
tsuji,
tried that only problem is that although it looks like uppercase when the name is submitted back to the DataBase the Customer name is still lowercase

Regards

Olly
 
optjco,

Yes, that's why it's until...

Howabout trying this.
Code:
sub toUpperCase
    txtCust.value=ucase(txtCust.value)
end sub
- tsuji
 
Further notes:

In case---very likely so---your input tag is within a form, say named "test", then always within the spirit of what ChristHirst advised you already, for onkeyup event, it would be something like this.
Code:
sub toUpperCase
    document.forms("test").txtCust.value = ucase(document.forms("test").txtCust.value)
end sub
- tsuji
 
tsuji
where would i put this code, i am only just starting out and i am struggling to make it work
 
optjco,

If your experience here is very limited, it is fair enough to have a bit of struggling. An example will put you on the track.
Code:
<html>
<head>
<script language="vbscript">
sub show
	msgbox document.forms("test").txtCust.value
end sub

sub toUpperCase
	document.forms("test").txtCust2.value=ucase(document.forms("test").txtCust2.value)
end sub
</script>
</head>
<body>
<form name="test">
<input name="txtCust"  type="text" style="text-transform: uppercase" id="txtCust" size=18 maxlength=15 onKeyup="show"><br>
<input name="txtCust2" type="text" id="txtCust2" onKeyup = "toUpperCase" size=18 maxlength=15>
</form>
</body>
</html>
(no server-side here, add your action for the form.)

- tsuji
 
<input type="text" .... value="<%=ucase("inputname")%>"


thats just an example...

Known is handfull, Unknown is worldfull
 
tsuji,
thanks for all the help. the code is working fine now.
A star is on it's way. also one for Chris for the info he gave me
Regards

Olly

[2thumbsup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top