Solved

C#, ASP.NET 2.0, Textbox validation question

Posted on 2007-03-21
2
584 Views
Last Modified: 2013-12-17
I have a web form that has two textboxes on it.  I want to be able to validate that at least one of these boxes is blank before sending the request back to the server.  

If txtbxA.Text = "Something" then txtbxB.Text = ""  or
If txtbxB.Text = "Something" then txtbxA.Text = "" 

I have found ways to validate them to be equal to each other or to be equal to a specific value, but cannot figure out how to validate that one is always blank.

This is probably really easy, and I apologize if it is a stupid question, but I haven't worked much with web forms.  Any help is extremely appreciated.

Thanks
0
Comment
Question by:CantonMarko
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 13

Accepted Solution

by:
KarinLoos earned 500 total points
ID: 18766581
I normally check the length property of the text to determine if a string is empty.
so ( in c#  something like )
if ( ( textbox1.text.length > 0 & textbox2.text.length == 0) || ( textbox1.text.length == 0 & textbox2.text.length > 0 ) )
{
   // ok to proceed
}
0
 

Author Comment

by:CantonMarko
ID: 18766633
I cannot believe that I was so dumb!!!!  That was just too obvious.  Thank you very much for the suggestion.  It works just fine.  
0

Featured Post

Containers & Docker to Create a Powerful Team

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question