Manoj Singh
Manoj Singh

Reputation: 7707

Allowing * in regular expression for alpha numeric

I have below code in vb.net for validating alphanumeric characters, It is working fine for all alphanumeric characters, However I want to allow user, so that he can insert "*". Please provide me the new regular expression for the above issue.

 <tr>
                <td>
                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                    <asp:RegularExpressionValidator ID="revSearchCourse" runat="server" Display="Dynamic"
                        ControlToValidate="txtSearchCourse" ValidationExpression="^[0-9a-zA-Z]+$" ErrorMessage="The Course Name Should be Only Alphanumeric characters"></asp:RegularExpressionValidator>
                </td>
 </tr>

Upvotes: 0

Views: 2932

Answers (1)

Ahmad Mageed
Ahmad Mageed

Reputation: 96507

Just add the * character inside the character class, like this: ^[0-9a-zA-Z*]+$

Upvotes: 2

Related Questions