in my experienceI approached the problem by using ASCII character codes. If you have BBEdit, there's a pallette that shows all of those code next to their characters, so I used that to write an annoyingly long if statement with four "or" statements and two "and" statements imbedded in an or statement. Annoying, but effective. Here it is...
function alphaNumericCheck(theChar) {
if ((theChar < 48) || (theChar > 122) ||
((theChar > 57) && (theChar < 65)) ||
((theChar > 90) && (theChar < 97)) ) {
return false;
} else {
return true;
}
}
To call the function, you would say something like...
<input type="button" name="foo" value="my button"
onclick="alphaNumericCheck(this.value.charCodeAt(0))">
The part that says charCodeAt(0) will return the ASCII number for the character at the zeroth position in the string (the first character). The function will take that character and return "false" if it's not a number, a capital letter or a lowercase letter, and "true" if it is alphanumeric. Try it.