Hi,
Please refer below code.
HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
var specialKeys = new Array();
specialKeys.push(35); //#
specialKeys.push(37); //%
specialKeys.push(43); //+
specialKeys.push(45); //-
specialKeys.push(61); //=
specialKeys.push(64); //@
$(function () {
$('input[type=text],textarea').on('keypress', function (e) {
var ret;
var keyCode = e.keyCode == 0 ? e.charCode : e.keyCode;
ret = ((keyCode >= 48 && keyCode <= 57) || (keyCode >= 65 && keyCode <= 90) || (keyCode >= 97 && keyCode <= 122) || (specialKeys.indexOf(e.keyCode) != -1 && e.charCode != e.keyCode));
if (specialKeys.indexOf(keyCode) != -1) {
ret = true;
}
if (!ret) {
alert('Special characters not allowed');
}
return ret;
});
});
</script>
</div>
Enter Name
<input type="text" />
<br />
Enter Address
<textarea></textarea>
<br />
Enter City
<input type="text" />
</form>
</body>
</html>
Demo