Been playing around with JavaScript, and what Im trying to do is only allow certain characters in the pass word field - a-z, A-Z and 0-9.
You need to make your condition test a regexp, not a string:
if(!/^[a-zA-Z0-9]+$/.test(name)){ ...
meaning:
^ -- start of line[a-zA-Z0-9]+ -- one or more characters/numbers$ -- end of lineor you could search for the inverse of that, which is "any non-accepted character":
if(/[^a-zA-Z0-9]/.test(name)){