How To Remove Special Characters From TextBox

How To Remove Special Characters From TextBox

Hi guys, in this tutorial i will explain you hot to remove special characters from textbox itself by using javascript.This is cool feature through which we can remove special characters at client side.

Design View:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html>

<html xmlns="">
<head runat="server">
<title>Hightechnology - Technology That Teach You</title>
<style type="text/css">
.auto-style1 {
width: 900px;
<script type="text/javascript">
function RemoveSpecialChar(txt) {
if (txt.value != '' && txt.value.match(/^[\w ]+$/) == null) {
txt.value = txt.value.replace(/[\W]/g, '');
<form id="form1" runat="server">
<table class="auto-style1" align="center">
<asp:TextBox ID="txt" runat="server" onkeyup="javascript:RemoveSpecialChar(this)"></asp:TextBox></td>

One thought on “How To Remove Special Characters From TextBox

  1. Simona

    That is a good tip particularly to those new to the blogosphere. Simple but very accurate information?? Thank you for sharing this one. A must read article!

Comments are closed.