Skip to content

Instantly share code, notes, and snippets.

@jacobwise
Created November 12, 2015 19:53
Show Gist options
  • Save jacobwise/c2283ef49fb3ec30b832 to your computer and use it in GitHub Desktop.
Save jacobwise/c2283ef49fb3ec30b832 to your computer and use it in GitHub Desktop.
Checks if input has illegal characters. I was using it to see if the user already had a valid username.
hasOriginalUsername: function() {
var illegalChars = new RegExp(/\W/); // allow letters, numbers, and underscores
if ( illegalChars.test( this.originalUsername ) ) {
return true;
} else{
this.username = this.originalUsername;
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment