Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If statement for custom validator

Status
Not open for further replies.

boatdrinks

IS-IT--Management
Jun 18, 2004
51
US
I am using a custom validator to check the value of a drop-down. if the value = something, then I want the textbox next to it to require a string of 8 characters.

Here is my function

Sub validatebarcode(source as Object, value as ServerValidateEventArgs)

If inserthardware.selecteditem.value="something" Then
'a string of 8 characters is required for textbox1

end if
End sub

I don't know how to write this code the then statement.
 
Handle it in the Server Validate event. VB should go something like this. I use C# so take it with a grain of salt.
Code:
Private Sub CustomValidator1_ServerValidate(ByVal source As Object, _
& ByVal args As ServerValidateEventArgs)
Handles CustomValidator1.ServerValidate
If args.Value.ToString() = "Something" Then
   args.IsValid = false
else
   args.IsValid = true
end if
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top