Solved

Easiest way to compare two textboxes have the same text?

Posted on 2009-04-15
5
238 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
[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
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

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

627 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