Create alphanumerical TextBox in ASP.Net using Javascript

– Create alphanumerical TextBox in ASP.Net

– Create alphanumerical TextBox in Javascript

Here we are going to learn how to create a only alphanumeric TextBox in ASP.Net application.
Alphanumeric means TextBox allow only alphabetic and Numeric value.

Here we can solve this example using javascript events.

¬†Write below javascript function code in your Head tag : –

<head runat=”server”>
<title>Create Alphanumeric TextBox</title>
<script type=”text/javascript”>

function EnteralfanumericOnly(val) {
var valuee = (val.which) ? val.which : key.valuee

if (!(valuee==8 || valuee==46)&&(valuee < 48 || valuee > 57) && (valuee < 97 || valuee > 122)) {
return false;
else {
return true;


– Write below code in Body tag for design web forms:-

<form id=”form1″ runat=”server”>
<table style=”z-index: 100; left: 432px; position: absolute; top: 168px”>
<td style=”width: 289px”>
<strong>Allow only alphanumeric value in TextBox</strong></td>
<td style=”width: 289px”>
<asp:TextBox ID=”txtFname” runat=”server” onkeypress=”return EnteralfanumericOnly(event)” Width=”168px”></asp:TextBox></td>

The output of alphanumerical textbox using javascript is like:

Create alphanumeric Textbox in ASP.Net
Create alphanumeric Textbox in ASP.Net

I hope this example of javascript will help you….

Author: Meera Academy

Leave a Reply

Your email address will not be published. Required fields are marked *