It would help you... assume you have a form with "formname" form and a text box with "txt" name. then you can use following code to allow only aphanumeric values
var checkString = document.formname.txt.value;
if (checkString != "") {
if ( /[^A-Za-z\d]/.test(checkString)) {
alert("Please enter only letter and numeric characters");
document.formname.txt.focus();
return (false);
}
}