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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validate 2 textboxes - 1 must be filled in

Status
Not open for further replies.

davida37

IS-IT--Management
May 10, 2006
113
GB
Hi there,

I am using VS2005 - .NET framework 2.

I have 2 textboxes on a form:
- txtEmailAddr
- txtCustomerNumber

I need to be able to validate that either 1 is populated. I can find lots of examples of validating all fields seperately i.e. :

<asp:textbox id="txtEmailAddr" runat="server" size="40"></asp:textbox><asp:requiredfieldvalidator id="rvEmailAddr" runat="server" display="None" errormessage="Please provide EmailAddr" controltovalidate="txtEmailAddr"></asp:requiredfieldvalidator>

..But I cannot find conditional validation - i.e. if 1 out of the 2 is filled in.

I assume I need a custom validator? but kind find good examples.

Please help.

thanks
david
 
use a custom validator and place your logic in the validation event. NOTE: unless you define some custom js to validate the client as well, the controls will only be validated on the server. so if client validation fails due to some other control, this custom validation won't execute.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top