regex for username validation javascript code example Example: javascript regex for usernames var usernameRegex = /^[a-zA-Z0-9]+$/;