E
EDOnLine
New asp.net/webform user question......
I am trying to use the Custom Validator control to check to see if either of
two fields on my form have been filled in. At this point all I am
interested in is if the user has entered a value into EITHER input box (not
left blank). Below is my control code and also my function. I guess my
question is, What should I be testing for in my function? I have tried many
things (checked the length of the textbox, null, empty string, etc.) and
nothing seems to be working (it returns TRUE).
However, if I test to see if either of the textboxes has a particular value
("1" for example), it works just fine (returns FALSE). So my theroy now is
that I am not testing for null or a empty textbox correctly. What is the
correct test for this?
<asp:CustomValidator runat="server" id="custPhonePagerCheck"
ControlToValidate="txtPhone" OnServerValidate="PhoneNumberCheck"
ErrorMessage="Phone or Pager Number is Required" />
Sub PhoneNumberCheck(sender as Object, args as ServerValidateEventArgs)
If args.value = "" AND txtpager.text = "" Then
args.IsValid = False
Exit Sub
End If
args.IsValid = True
End Sub
Much thanks in advance for any help!
-- Eric
I am trying to use the Custom Validator control to check to see if either of
two fields on my form have been filled in. At this point all I am
interested in is if the user has entered a value into EITHER input box (not
left blank). Below is my control code and also my function. I guess my
question is, What should I be testing for in my function? I have tried many
things (checked the length of the textbox, null, empty string, etc.) and
nothing seems to be working (it returns TRUE).
However, if I test to see if either of the textboxes has a particular value
("1" for example), it works just fine (returns FALSE). So my theroy now is
that I am not testing for null or a empty textbox correctly. What is the
correct test for this?
<asp:CustomValidator runat="server" id="custPhonePagerCheck"
ControlToValidate="txtPhone" OnServerValidate="PhoneNumberCheck"
ErrorMessage="Phone or Pager Number is Required" />
Sub PhoneNumberCheck(sender as Object, args as ServerValidateEventArgs)
If args.value = "" AND txtpager.text = "" Then
args.IsValid = False
Exit Sub
End If
args.IsValid = True
End Sub
Much thanks in advance for any help!
-- Eric