Click to See Complete Forum and Search --> : Custom Validator Control not working!


bsaucer
May 19th, 2004, 03:16 PM
I have a form with two text boxes and a button. For each text box I have a RequiredFieldValidator, and a ValidExpressionValidator (must be 1 to 3 digit integer). These are working as expected.

In addition to those, I have a single CustomValidator. The server-side script for this control checks to see if the lengths of the two integers add up to four.

The ControlToValidate property is blank since it is validating two text boxes at once. When I click the button, I expect the following code to execute:


Private Sub CustomValidator1_ServerValidate(ByVal source As System.Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs)
If Len(TextBox1.Text) + Len(TextBox2.Text) = 4 Then
args.IsValid = True
Else
args.IsValid = False
End If
End Sub

ABudair
May 23rd, 2004, 07:49 AM
Hi,

Check that RequiredFieldValidator and RegularExpressionValidator (Enable Client side) property, and set them to false.

EnableClientScript = false

i hope it helps.

if its not Clarrification me when u want the validator return true.
sure that when the summation of lengths of two boxes equals to 4, or vise versa.

I worked with validators toooo much, and i think i could solve it.

bye.