Solved

Easiest way to compare two textboxes have the same text?

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
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.…
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…

734 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