Click here to Skip to main content
16,012,821 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how can I force user to write chracter such as @ or : in textbox using validating textbox
best regards
Posted
Comments
RaisKazi 1-Sep-11 6:46am    
Do you mean to say, You only want to accept text from user which contains "@" or ":"?.
somur-ruteeb 1-Sep-11 7:12am    
yes
RaviRanjanKr 1-Sep-11 6:51am    
Not Clear. be more specific while asking question. we need more information.
[no name] 1-Sep-11 6:56am    
He probably simply wants to validate a mail address. Instead of 'forcing' users to do anything, we use a regex for that nowadays. The downside is that a foolproof regex for mailaddresses (if that's indeed the purpose) is practically impossible.
RaviRanjanKr 1-Sep-11 7:07am    
Might be he is looking for validate a mail address. but I unable to understand is there any use of ':' in email address.

There are two ways to do it: you can handle the TextBox events (TextChanged, and Validating are probably the most use to you) or you could use a MaskedTextBox which will allow you to specify exactly what input you need.
 
Share this answer
 
Comments
somur-ruteeb 1-Sep-11 7:02am    
would you please give me an example
Here[^] is a very simple article on text box validation.
It should give you enough ideas to start trying to implement a solution for your this problem.
 
Share this answer
 
Comments
somur-ruteeb 1-Sep-11 7:09am    
this link didn't open
Hi,

i think you have to use Regular Expression to validate Textbox (accept string has format meets the regular expression format)

follow this link it may be useful http://www.codeproject.com/KB/recipes/RegexTester.aspx

good luck,
 
Share this answer
 
v3
Comments
somur-ruteeb 1-Sep-11 7:22am    
would you please give me an example
somur-ruteeb 1-Sep-11 7:29am    
this link didn't open
Mahmud Mostafa 1-Sep-11 8:09am    
the solution has improved
It looks like you're validating an email address, and this is one of the very few times I'd recommend using the RegularExpression object. You can find examples of applying a regular expression to an email address all over google.
 
Share this answer
 
v2

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