How To Remove Special Characters from Text box Using JavaScript in C# Asp.Net
Program:
.Aspx File:
Program:
.Aspx File:
<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> |
Live Demo:
Enter Text:
|
No comments:
Post a Comment