Click here to Skip to main content
15,891,843 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a textbox that the user can only enter characters in a certain order into to enable a button. I would like it to be like this: (N = 'number' and L = 'letter')
C#
IF textBox1 contains character order of (NNNNNLNN-NNNL-NNLL-NLNN-LNNLLLNNLLLL)
    { button1.Enabled = true; }
ELSE { button1.Enabled = false; }

So I want to enable the button if the order and amount of letters, numbers and dashes is in the correct combination of NNNNNLNN-NNNL-NNLL-NLNN-LNNLLLNNLLLL. How would I do this in C#. Thanks
Posted
Comments
BillWoodruff 5-Oct-13 21:34pm    
What have you tried so far ? Is this WinForms ? ASP.NET ?

1 solution

I recommend using Regex to determine this.  See this[^] awesome Regex tutorial and this[^] page to test your Regex expression.

/ravi
 
Share this answer
 
Comments
BillWoodruff 7-Oct-13 0:30am    
Those are excellent resources, Ravi.

thanks, Bill

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