Solved

Easiest way to compare two textboxes have the same text?

Posted on 2009-04-15
5
205 Views
Last Modified: 2012-05-06
I have 2 textboxes:

Textbox1
Textbox2

The user must enter in values to both these texboxes but I need to ensure that the values entered into these textboxes match.

So what would be the simplest way to compare both these textboxes, without prompting a message box for every character entered.

I have tried doing it in the LostFocus Event and the TextChanged event. If there are any other recommendations I would love to hear them.

Cheers
0
Comment
Question by:directxBOB
5 Comments
 
LVL 19

Expert Comment

by:alb66
ID: 24148564
If in the page there is a button like "OK" or "Submit" or "Next", I'd check the values on the click event for that button
0
 

Author Comment

by:directxBOB
ID: 24148591
I have those checks in place, but the customer wants a realtime check while the user is focused on the two texboxes. The end user of this system would not be consider computer literate at all, nor do they care much for computers. So trying to get them to find a textbox/field to enter into could be a challenge.
0
 
LVL 16

Accepted Solution

by:
CuteBug earned 200 total points
ID: 24148634
You can also show a picturebox alongside TextBox2.
Handle the TextChangedEvent of the textboxes.
As long as the password doesn't match, show an error icon in the picturebox.
If the password match, show a green tick icon indicating that the passwords are matching.
0
 
LVL 19

Assisted Solution

by:alb66
alb66 earned 200 total points
ID: 24148637
In order to avoid message box while entering the text, you can display a static text (or an icon) near the text boxes while the two text are different. In this case you can do the compare in the TextChanged event
0
 

Assisted Solution

by:HuntedBounty
HuntedBounty earned 100 total points
ID: 24154819
why not make a button, and when its clicked it checks if the text boxes match?

if(textbox1.text == texbox2.text)
{
  // if both of these text boxes are equal then do something here
  messagebox.show("ok it works"); // you can change this to anything
}

hope this answers your question :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

929 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now