PDA

Click to See Complete Forum and Search --> : Validate Event!


ChrisM
Dec 13th, 1999, 08:20 PM
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?

Serge
Dec 13th, 1999, 09:12 PM
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.

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
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)

ChrisM
Dec 14th, 1999, 11:25 AM
Yep I know about the validate event!
But like I said the problem is getting it to fire within a HTML page in IE5!!