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

onKeyPress gives errors

Status
Not open for further replies.

thunderain

Programmer
Jan 10, 2002
40
CA
I am programming in ASP with VBScript. I have a function which is visual basic. It puts letters in uppercase and also weeds out all sybols such as $,%, etc. I am trying to call it from a form field but having trouble.



The funtion:
(I have this in the head, tried in different spots)

<script language=&quot;VB&quot;>
<!--
Private Sub txtLP_KeyPress(KeyAscii As Integer)

Dim c$
Dim n%

If KeyAscii <> 8 Then
n = 0
If Len(txtLP) <= 12 Then
c = Chr$(KeyAscii)
c = UCase(c)
If c < &quot;A&quot; Or c > &quot;Z&quot; Then
If IsNumeric(c) Then
n = Asc(c)
End If
Else
n = Asc(c)
End If
End If
KeyAscii = n
End If

End Sub

//-->
</script>




<input type=&quot;text&quot; name=&quot;BlackLP&quot; size=&quot;40&quot; onkeypress=&quot;txtLP_KeyPress(KeyAscii)&quot;><br>

also tried:

onkeypress=&quot;return txtLP_KeyPress(BlackLP)&quot;
onkeypress=&quot;txtLP_KeyPress(BlackLP)&quot;
onkeypress=&quot;return txtLP_KeyPress()&quot;

Also tried declaring funtion as:

Function txtLP_KeyPress(KeyAscii)
Function txtLP_KeyPress(BlackLp)
Function txtLP_KeyPress()



I keep getting error &quot;KeyAscii is undefined&quot; Trying some of the others, i get error &quot;Object expected&quot;

Am i ok declaring the script as VB and using it? Why is my onKeyPress not working? How do I call the function with onKeyPress (or is there a better way)?

thank you
thunderain
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top