Try this function instead:
function IsAlphaNumeric(e) {
var keyCode = e.keyCode == 1 ? e.charCode : e.keyCode;
var ret = ((keyCode > 31 && keyCode < 127) && keyCode != 38 && keyCode != 60 && keyCode != 62);
document.getElementById("error").style.display = ret ? "none" : "inline";
return ret;
}
It will allow any character with
ASCII code[
^] from 32 to 126 apart from < and > and &
YOu can easily add or exclude others.
Also, just to add: do not rely on JavaScript (client side) validation for user input. You must always run the same checks in code (VB, C#, whatever) on the server as well.