Click here to Skip to main content
15,941,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all,

in my form i have text box, in that textbox i ll pass value like A1 A2 A3 A4, If again pass A1 or any of the abouve value its should alert me, how shall i do it
Posted
Comments
Abdul Quader Mamun 15-Dec-10 11:24am    
Home Work!
sameertm 15-Dec-10 11:25am    
u mean?
Abdul Quader Mamun 15-Dec-10 11:27am    
Just check every two characters like "A1" in text box before inserting every A1, A2 & so on.
sameertm 15-Dec-10 11:28am    
how shall i check can u give me some idea!
Abdul Quader Mamun 15-Dec-10 11:31am    
Yes Of course!

1 solution

You can check by doing something like:
(This example is in c#, but you should get the point)
if (!TextBox1.Text.Contains(value_to_be_inserted))
{ 
TextBox1.Text += value_to_be_inserted;
}


Beware though, this assumes that strings to be added will not be partial strings of strings already contained in the text box. To check for that, you will probably need to use a delimiter: white space, comma, etc, whatever works according to your data. Or if needed, you could store each string as you add them into a list and check against that.
 
Share this answer
 
v4
Comments
sameertm 15-Dec-10 12:08pm    
its works coo; :)
wizardzz 15-Dec-10 12:23pm    
You do fully understand the caveat I mention in the last paragraph right? It might not work if "codeproject" is in the textbox, and you try to add "project." In this case it won't add project.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900