Results 1 to 5 of 5

Thread: Form Keypress Event

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2000
    Location
    Sudbury, Ontario, Canada
    Posts
    274

    Form Keypress Event

    I have a web page form that I want to validate.

    How can I capture the Ascii code for the onKeyPress event of a web page textbox?

    Such as (VB Code):
    Code:
    Private Sub txtFileNum_KeyPress(KeyAscii As Integer)
        If KeyAscii >= 97 And KeyAscii <= 122 Then
            KeyAscii = Asc(UCase(Chr(KeyAscii)))
        End If
    End Sub
    Thanks in advance.

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2000
    Location
    Sudbury, Ontario, Canada
    Posts
    274
    All I want to do is capture what key is being press in a textbox.

    I would appreciate any help?

  3. #3
    sarun
    Guest
    Does this help you?

    <HEAD>
    <SCRIPT>
    </SCRIPT>
    <SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
    <!--
    function text1_onkeypress() {
    alert( window.event.keyCode);
    }
    //-->
    </SCRIPT>
    </HEAD>
    <BODY>
    <form name=form1>
    <input type=text name=text1 LANGUAGE=javascript onkeypress="return text1_onkeypress()">
    </form>
    </BODY>

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2000
    Location
    Sudbury, Ontario, Canada
    Posts
    274
    I was hoping for VBScript but that will work.

    Thank you.

  5. #5
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    Pretty much the same:

    Code:
    <SCRIPT ID=clientEventHandlersVBS LANGUAGE=VBScript> 
    Sub text1_onkeypress 
        window.alert window.event.keyCode 
    End Sub
    </SCRIPT>
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width