I have a bit of code that transforms user input to ensure the only allowed characters are abcdefghijklmnopqrstuvwxyz-0123456789
https://jsfiddle.net/py4pnr0L/
value = 'GHJHlk;sxa787BVK'
value = value.toLowerCase()
value = value.replace(/[^a-z0-9\-]/gi, '-')
console.log(value)
Returns: ghjhlk-sxa787bvk
How would I go about not transforming, but just testing to find if a given string contains characters outside the permitted range?
All I want to know is true/false for a given input string.
I am using ES2015 so if the cleanest solution is available using ES2015 then that is fine.