|
-
Nov 30th, 2004, 11:25 AM
#1
Thread Starter
Fanatic Member
upper case
What is the easiest way to convert the text in a text box to upper case as you are typing the letters?
Thanks
-
Nov 30th, 2004, 12:22 PM
#2
Frenzied Member
You would have to use javascript to do that by capturing the keypressdown event.
Being educated does not make you intelligent.
Need a weekend getaway??? Come Visit
-
Nov 30th, 2004, 12:36 PM
#3
Thread Starter
Fanatic Member
I believe there is no keypressdown event.
-
Nov 30th, 2004, 02:01 PM
#4
New Member
Code:
<html>
<head>
<script language="javascript">
function MakeCaps(t)
{
var tmp;
tmp = t.value;
t.value = tmp.toUpperCase();
}
</script>
</head>
<body>
<form name=form1>
<input type=text name=txtUsername onkeyUp="javascript:MakeCaps(this);">
</form>
</body>
</html>
-
Dec 2nd, 2004, 12:16 PM
#5
Frenzied Member
Originally posted by fmardani
I believe there is no keypressdown event.
I meant just capturing the key events, such as key down, key up, key press, etc....
Being educated does not make you intelligent.
Need a weekend getaway??? Come Visit
-
May 2nd, 2005, 05:02 PM
#6
Re: upper case
Is there a way to do this using an asp control, rather than a html control?
-
May 3rd, 2005, 10:25 AM
#7
Re: upper case
Maybe somebody can help me with the following javascript:
Code:
<script language=javascript>
function inspectEvent(evt){
if (evt.keyCode == 13)return false;
if (evt.keyCode > 96 && evt.keyCode < 123)return evt.keyCode - 32;
}</script>
The first if disables the enter button. I'm trying to use the same function to trap lowercase keystrokes, and convert them to upper case.
-
May 3rd, 2005, 12:52 PM
#8
Re: upper case
For anybody interested:
Code:
<HEAD>
<script language=javascript>function inspectEvent(evt){
if (evt.keyCode >= 97 && evt.keyCode <= 122)
{
Alpha=String.fromCharCode(evt.keyCode).toUpperCase();
evt.srcElement.value=evt.srcElement.value + Alpha;
return false;
}
else if (evt.keyCode == 13)return false;
}</script>
</HEAD>
VB Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Form1.Attributes.Add("onkeypress", "return inspectEvent(event)")
End If
End Sub
Last edited by wild_bill; May 3rd, 2005 at 01:04 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|