Solved

C#, ASP.NET 2.0, Textbox validation question

Posted on 2007-03-21
2
576 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
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Groupbox Control ? 2 27
Convert Silverlight ERP To Angularjs,HTML5 3 56
Asp.Net Session Question 2 33
locate sql commands in C# visual studio Project 6 37
Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

713 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