I'm writing a form validation function and would like to verify that a field only contains alphanumeric characters.
How should I structure that statement?
The following seems logical but doesn't work;
if(document.getElementById('RegisForm_Username').value == /[^a-zA-Z 0-9]/g)
alert("I'm sorry, your username must be alphanumeric (consisting of the letters A-Z or numbers 0-9) and cannot have any special characters.");