Results 1 to 3 of 3

Thread: Validate Event!

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 1999
    Location
    Nottingham
    Posts
    20

    Post

    Could anyone help me!

    I have created an activeX control (which happens to be a cut down text box) which will be displayed on an HTML form in IE5.
    What I want to know is does anyone out there know how to fire the validate event (which I have mapped to the text box) from the HTML form. I have set the causes validation property to true so why won't it work?

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    Validate Event - Occurs before the focus shifts to a (second) control that has its CausesValidation property set to True.

    Here is an example from MSDN:
    Place 2 text boxes on the form and 1 command button.
    Code:
    Private Sub Form_Load()
       ' Set the button's CausesValidation property to False. When the user
       ' clicks the button, the Validate event does not occur.
       ' Set the Caption property of the button to "Help".
       With Command1
          .CausesValidation = False
          .Caption = "Help"
          End With
          Show
       With Text1 ' Select text of Text1 and set focus to it.
          .SelLength = Len(Text1.Text)
          .SetFocus
          End With
    End Sub
    Private Sub Command1_Click()
        ' Give the user help when the button is clicked.
       MsgBox "Text1 must be set to a date." & vbCrLf & _
                                        "Text2 must be a number less than 10."
    End Sub
    
    Private Sub Text1_Validate(KeepFocus As Boolean)
       ' If the value is not a date, keep the focus, unless the user
       ' clicks Help.
        If Not IsDate(Text1.Text) Then
            KeepFocus = True
            MsgBox "Please insert a date in this field.", , "Text1"
        End If
    End Sub
    
       Private Sub Text2_Validate(KeepFocus As Boolean)
       ' If the value is a number larger than 10, keep the focus.
        If Not IsNumeric(Text2.Text) Or Val(Text2.Text) > 10 Then
            KeepFocus = True
            MsgBox "Please insert a number less than or equal to 10.", , "Text2"
        End If
    End Sub



    ------------------

    Serge

    Software Developer
    [email protected]
    [email protected]
    ICQ#: 51055819


  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 1999
    Location
    Nottingham
    Posts
    20

    Post

    Yep I know about the validate event!
    But like I said the problem is getting it to fire within a HTML page in IE5!!

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