Write below javascript code:-
<script language="javascript" type="text/javascript">
function RemoveSpecialChar(txtVal)
{
if (txtVal.value != '' && txtVal.value.match(/^[\w ]+$/) == null)
{
txtVal.value = txtVal.value.replace(/[\W]/g, '');
}
}
</script>
<asp:TextBox ID="txtName" onkeyup="javascript:RemoveSpecialChar(this)" runat="server">