Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
1.30/5 (3 votes)
See more:
I have to Enter in to an Sector text, it has to come like this /AAA/AAA/AAA/AAA/AAA/,ITS ALREADY THE TEXT HAS SET AS WHEN WE HAD ENTERED IN TO THAT TEXT IT WILL SHOWS LIKE THIS __/__/__/__/__

PLS HELP ME SIR?
Posted
Updated 20-Apr-23 19:59pm
v3
Comments
Rajeev Jayaram 1-Feb-12 1:44am    
What do you mean? You don't want '/' as the input?

 
Share this answer
 
Add a KeyPress event handler on the TextBox.
Then put in this code into the textbox. This will allow only alphabets or /.

C#
private void textBox_KeyPress(object sender, KeyPressEventArgs e)
{
    if (!Regex.IsMatch(textbox.Text, @"[a-zA-Z/]"))
    {
        e.Handled = true;
    }
}
 
Share this answer
 
C#
<pre>Regex rx = new Regex(@"^[a-zA-Z]+$");

if(!rx.IsMatch(TextBox1.Text)){

//code for handling error

}



Also, refer to this article for an understanding about regular expressions.

"http://www.codeproject.com/KB/cs/Regular_Expressions.aspx"
 
Share this answer
 
v4
Here is an excellent CP article for your reference,
Enhanced Textbox Control[^]

Some links that would help,
http://forums.asp.net/t/1272776.aspx/1[^]
SOF[^]
 
Share this answer
 

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