Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Easiest way to compare two textboxes have the same text?

Posted on 2009-04-15
5
Medium Priority
?
243 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 800 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 800 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 400 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

670 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