.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

Regular Expression for Alphanumeric only for input control

Posted By: priya     Posted Date: December 03, 2009    Points:2   Category :ASP.Net

I need Regular Expression for Alphanumeric only for input control. My requirement is user can not enter other than alphanumeric value in a text box.

I am using C# and ASP.net

Thanks In Advance

Author: Venkat             
Posted Date: December 04, 2009     Points: 5   

You can use this regular expression for checking alphanumeric.

You can use Regular expression validator control and associate this validation control to the Input TextBox

Expression is


Mark As Answer if this solve your problem
Warm Regards,
Author: Prasanti Prusty             
Posted Date: December 17, 2009     Points: 5   


You can use Javascripts to validate this as followes.

Define the Function "isNumberEvt" on Head Section. and cakl it on keypress even of text box like "onkeypress="return isNumberEvt(event)"".

<head runat="server">
<title>Untitled Page</title>
<script language="javascript" type="text/javascript">
function isNumberEvt(evt)
var charCode = (evt.which) ? evt.which : event.keyCode

if ((charCode > 31 && charCode < 48 ) || (charCode > 57 && charCode < 65 ) || (charCode > 90 && charCode < 97) || (charCode > 122))
return false;

return true;
<form id="form1" runat="server">
<asp:TextBox ID="TextBox1" runat="server" Width="238px" onkeypress="return isNumberEvt(event)"></asp:TextBox></div>


Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend