Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Validation of 2 Textboxes

Reply
Thread Tools

Validation of 2 Textboxes

 
 
RChase
Guest
Posts: n/a
 
      08-09-2006
Here is my situation:

I have two fields (let's call them FieldA and FieldB). If FieldA contains a
value then FieldB cannot, and if FieldB has a value FieldA cannot.

Is there a way using the Validation controls to check for this?
 
Reply With Quote
 
 
 
 
marss
Guest
Posts: n/a
 
      08-10-2006

RChase написав:
> Here is my situation:
>
> I have two fields (let's call them FieldA and FieldB). If FieldA containsa
> value then FieldB cannot, and if FieldB has a value FieldA cannot.
>
> Is there a way using the Validation controls to check for this?


Use CustomValidator. Add handler for ServerValidate event.

Something like this:

private void CustomValidator1_ServerValidate(object source,
System.Web.UI.WebControls.ServerValidateEventArgs args)
{
args.IsValid = ((FieldA.Text == "" && FieldB.Text != "") ||
(FieldA.Text != "" && FieldB.Text == ""));
}

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
password type textboxes - I don't want them cleared during validation Keith G Hicks ASP .Net 1 02-23-2008 07:59 PM
Validation for Two Textboxes Alphonse Giambrone ASP .Net 3 10-21-2004 06:43 PM
Validation of EditItemTemplate TextBoxes in a DataGrid =?Utf-8?B?bWc=?= ASP .Net 1 05-18-2004 05:36 AM
Can one validation control work for multiple textboxes? Russ ASP .Net 3 12-04-2003 10:26 PM
Re: only custom validation control does server side validation? Colin Mackay ASP .Net 0 06-25-2003 07:54 AM



Advertisments