You can use JavaScript key press event to restrict special characters as shown below.
<script type="text/javascript">
//this event can be attached in pageLoad or DOM Ready
function pageLoad() {
var specialCharsArray = [61, 62, 33, 36, 64, 35, 37, 94, 38, 42, 40, 96, 126, 40, 41, 43];
//this array can be used to specify all the special characters
//the element can be an id of a textbox or in general input type=text
element.bind("keypress", function (event) {
//check array
if ($.inArray(event.which, specialCharsArray ) != -1) {
event.preventDefault(); //prevent default event handle
}
});
}
</script>
Use this link to test key code values.
Cheers,
Samitha
<script type="text/javascript">
//this event can be attached in pageLoad or DOM Ready
function pageLoad() {
var specialCharsArray = [61, 62, 33, 36, 64, 35, 37, 94, 38, 42, 40, 96, 126, 40, 41, 43];
//this array can be used to specify all the special characters
//the element can be an id of a textbox or in general input type=text
element.bind("keypress", function (event) {
//check array
if ($.inArray(event.which, specialCharsArray ) != -1) {
event.preventDefault(); //prevent default event handle
}
});
}
</script>
Use this link to test key code values.
Cheers,
Samitha