thunderain
asked on
Uppercase Form Function
I am working in ASP with VBScript. I have a form which includes a licence plate field as such:
Licence Plate:
<input type="text" name="BlackLP" size="40"><br>
<input type="submit" value="SUBMIT" id="submit1" name="submit1" onClick="return validate()">
The customer gave me this snippet of code to have licence plate numbers revert to capitols as we
type them in. Here is his message and code:
Can you trap the keystrokes so that you can only enter uppercase letters and numbers for the LP.
Here is the snippet of code we use:
Private Sub txtLP_KeyPress(KeyAscii As Integer)
Dim c$
Dim n%
If KeyAscii <> 8 Then ' backspace
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
I do not know how to adapt it to the form in ASP and call it up. Can anyone help me?
Thank you
thunderain
Licence Plate:
<input type="text" name="BlackLP" size="40"><br>
<input type="submit" value="SUBMIT" id="submit1" name="submit1" onClick="return validate()">
The customer gave me this snippet of code to have licence plate numbers revert to capitols as we
type them in. Here is his message and code:
Can you trap the keystrokes so that you can only enter uppercase letters and numbers for the LP.
Here is the snippet of code we use:
Private Sub txtLP_KeyPress(KeyAscii As Integer)
Dim c$
Dim n%
If KeyAscii <> 8 Then ' backspace
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
I do not know how to adapt it to the form in ASP and call it up. Can anyone help me?
Thank you
thunderain
what browser's do you need to support? using styles is the easiest way.
<input type="text" name="BlackLP" size="40" style="text-transform:uppe rcase">
<input type="text" name="BlackLP" size="40" style="text-transform:uppe
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I already tried ucase(), but he wants the keystrokes trapped and put in uppercase as you type. (style make kestrokes uppercase in some browsers). The code also keeps out symbol keys. He would like this used or modified if possible.
I renamed the function --> Function txtLP_KeyPress(KeyAscii)
I tried --> onkeypress="txtLP_KeyPress (KeyAscii) " but get errors, KeyAscii is undefined.
I put in BlackLP in both places, get error --> Object expected
I think using onkeypress is close, just not quite set up right.
Again, is there a way to call this function? Am i declaring the function wrong at the top? (Function txtLP_KeyPress(KeyAscii) OR Function txtLP_KeyPress(BlackLP)
thank you
thunderain
I renamed the function --> Function txtLP_KeyPress(KeyAscii)
I tried --> onkeypress="txtLP_KeyPress
I put in BlackLP in both places, get error --> Object expected
I think using onkeypress is close, just not quite set up right.
Again, is there a way to call this function? Am i declaring the function wrong at the top? (Function txtLP_KeyPress(KeyAscii) OR Function txtLP_KeyPress(BlackLP)
thank you
thunderain
No comment has been added lately and it seems that this question have been abandoned. So it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question or invite a Moderator to close this question if there's no reply from you after seven days.
In the absence of responses, I will recommend the following:
To accept the comment and points awarded to zombeen
** PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER **
Just trying to help for the cleanup...
gladxml
I will leave a recommendation in the Cleanup topic area that this question or invite a Moderator to close this question if there's no reply from you after seven days.
In the absence of responses, I will recommend the following:
To accept the comment and points awarded to zombeen
** PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER **
Just trying to help for the cleanup...
gladxml
thks gladxml
Calling the function on keypress event of the associated textbox
<input type="text" name="BlackLP" size="40" onkeypress="txtLP_KeyPress
Zombeen