Skip to content

Instantly share code, notes, and snippets.

@KimSarabia
Created October 4, 2017 20:16
Show Gist options
  • Save KimSarabia/2ddf7a7589255fe97846a944e025a4cc to your computer and use it in GitHub Desktop.
Save KimSarabia/2ddf7a7589255fe97846a944e025a4cc to your computer and use it in GitHub Desktop.
Reject Special Characters Regex
Determine if any characters are not in character classes a-z, A-Z or 0-9
This will also treat é or similar characters as rejected symbols.
if(!/[^a-zA-Z0-9]/.test($(this).val())) {
$("#passwordErrorMsg").html("OK");
}
Source: https://stackoverflow.com/questions/19932596/regex-to-not-allow-special-characters-javascript
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment