Character matching
-
I want user to enter A-Z or 0-9 only. what's wrong with this RegularExpressions.Regex reg = new RegularExpressions.Regex("[a-zA-Z0-9]"); if i enter :hello or _hello or !hello it says it's valid but its not if (reg.IsMatch(textfield1.Text)) { } Thanks for helping me out in advance
-
I want user to enter A-Z or 0-9 only. what's wrong with this RegularExpressions.Regex reg = new RegularExpressions.Regex("[a-zA-Z0-9]"); if i enter :hello or _hello or !hello it says it's valid but its not if (reg.IsMatch(textfield1.Text)) { } Thanks for helping me out in advance
You need to say that it must match at the begining and end with ^ and $ and you need to allow 1 or more matches with + ^[a-zA-Z0-9]+$
Take care, Tom ----------------------------------------------- Check out my blog at http://tjoe.wordpress.com