thunderain
Programmer
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="VB">
<!--
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 < "A" Or c > "Z" 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="text" name="BlackLP" size="40" onkeypress="txtLP_KeyPress(KeyAscii)"><br>
also tried:
onkeypress="return txtLP_KeyPress(BlackLP)"
onkeypress="txtLP_KeyPress(BlackLP)"
onkeypress="return txtLP_KeyPress()"
Also tried declaring funtion as:
Function txtLP_KeyPress(KeyAscii)
Function txtLP_KeyPress(BlackLp)
Function txtLP_KeyPress()
I keep getting error "KeyAscii is undefined" Trying some of the others, i get error "Object expected"
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
The funtion:
(I have this in the head, tried in different spots)
<script language="VB">
<!--
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 < "A" Or c > "Z" 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="text" name="BlackLP" size="40" onkeypress="txtLP_KeyPress(KeyAscii)"><br>
also tried:
onkeypress="return txtLP_KeyPress(BlackLP)"
onkeypress="txtLP_KeyPress(BlackLP)"
onkeypress="return txtLP_KeyPress()"
Also tried declaring funtion as:
Function txtLP_KeyPress(KeyAscii)
Function txtLP_KeyPress(BlackLp)
Function txtLP_KeyPress()
I keep getting error "KeyAscii is undefined" Trying some of the others, i get error "Object expected"
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