Skip to content

Instantly share code, notes, and snippets.

@ConnectedReasoning
Last active October 17, 2017 14:21
Show Gist options
  • Save ConnectedReasoning/7ac7e7fb9fc7b6207ef3f88dcd8d8baa to your computer and use it in GitHub Desktop.
Save ConnectedReasoning/7ac7e7fb9fc7b6207ef3f88dcd8d8baa to your computer and use it in GitHub Desktop.
Simple alphanumeric space and underline and dash javascript validation
function validateField() {
return{
IsValidInput : function(input){
var isValid = false;
var validChars = /^[a-z\d\-_\s\/]+$/i;
if (validChars.test(input)){
isValid = true;
}
return isValid;
}
};
}
@ConnectedReasoning
Copy link
Author

Simple function for javascript whitelist validation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment