Reputation: 41
I need code for alpha numeric ,which is used in regular expression in asp.net to enter the data inside the textbox .
Upvotes: 4
Views: 14171
Reputation: 625
I guess below should be enough.
^[0-9A-Za-z]*$
Here is the break down
^ indicates start of the string
0-9 all number from 0 to 9
A-Z all Upper case character
a-z all small case character
* indicates 0 or more character
$ end of string
Upvotes: 1
Reputation: 22323
Regex for alpha numeric:
"^[a-zA-Z0-9]*$"
If you don't want empty strings, use + instead of *.
Upvotes: 3
Reputation: 689
Use this ValidationExpression="^[a-zA-Z0-9.@]{0,25}$"
. It accepts .
and @
symbol also. If not remove them
<asp:RegularExpressionValidator id="RegularExpressionValidator1" runat="server" ControlToValidate="TextBox1" ValidationExpression="^[a-zA-Z0-9.@]{0,25}$" ErrorMessage="Only Alphanumeric"></asp:RegularExpressionValidator>
Upvotes: 0