Removing special characters from the Textbox using JavaScript.

Vishalneeraj-24503
Posted by Vishalneeraj-24503 under JavaScript category on | Points: 40 | Views : 183
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">

Comments or Responses

Login to post response