Sunday, 6 July 2014

Remove Special Symbol

If you are looking for removal for special and junk characters, you can use
strings filename
otherwise, if you want to remove some specified special characters
you can do 

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Remove Special Characters from the Textbox using JavaScript</title>
<script language="javascript" type="text/javascript">
function RemoveSpecialChar(txtName) {
if (txtName.value != '' && txtName.value.match(/^[\w ]+$/) == null) {
txtName.value = txtName.value.replace(/[\W]/g, '');
}
}
</script>
</head>
<body>
<div>
<b>Enter Text:</b><input id="txtName"  type="text" onKeyUp="javascript:RemoveSpecialChar(this)" />
</div>
</body>
</html>

No comments:

Post a Comment