Allow Alphabets and Numbers (AlphaNumeric) with Comma and Underscore Special characters using RegularExpression in ASP.Net

info4me
 
on Nov 14, 2014 05:38 AM
16177 Views

Hi,

 

I need to allow only alphanumeric characters and only comma and underscore to be entered in the textbox.

Could anyone please let me know how to do this.

 

Thanks!

Download FREE API for Word, Excel and PDF in ASP.Net: Download
Andrea
 
on Nov 14, 2014 05:38 AM
Hi @info4me,
Please try the following

How to allow only numbers (Numeric TextBox) in ASP.Net MVC using JavaScript

It might help you.

Cheers Andrea.
Azim
 
on Nov 14, 2014 05:45 AM

Please refer this article

Regular Expression (Regex) to accept only Alphabets and Space in TextBox in ASP.Net

Change the  ValidationExpression to

ValidationExpression="[a-zA-Z0-9,_]*$" 

<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBox1"
            ValidationExpression="[a-zA-Z0-9,_]*$" ErrorMessage="*Valid characters: Alphabets and Special Characters (,_)." />