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 asp.net 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;
}
}
</script>
</head>

 

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

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

The output of asp.net alphanumerical textbox using javascript is like:

Create alphanumeric Textbox in ASP.Net

Create alphanumeric Textbox in ASP.Net

I hope this asp.net example of javascript will help you….

Leave a Reply

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

15 + 2 =