Click here to Skip to main content
14,865,088 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Need to have a regex for accepting alphabets or alphanumeric with the length of 6 to 15, and should not accept numeric only.
i have this one , ^[a-zA-Z0-9]+$.... but not according to my reg

Try this

Which I adapted after typing "Password" into the search engine at[^]
_Asif_ 7-May-14 4:25am
+5 :)
public bool IsAlphaNumeric(string inputString)
Regex r = new Regex("^[a-zA-Z0-9]+$");
if (r.IsMatch(inputString))
return true;
return false;

Verifying that textbox text contains only alphanumeric value as well as space character through Regular Expression Validator in (validation controls).

<asp:textbox id="txtName" runat="server" xmlns:asp="#unknown">

<asp:regularexpressionvalidator id="REValphaOnly" runat="server" errormessage="Please enter only alphanumeric." controltovalidate="txtName" validationexpression="^[a-zA-Z0-9]+$" xmlns:asp="#unknown">
CHill60 7-May-14 5:13am
That's code not a regular expression. OP did not ask how to use the regex
Try below one.


CHill60 7-May-14 4:02am
This will allow 6 - 15 numeric. Requirement is "and should not accept numeric only."

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